Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

CHAPTER 2 • The WordPress Syntax 29


Figure 2-3: The same post from Figure 2-2, but viewed in the older Twenty Thirteen theme.


You can use a really basic theme that simply outputs the content in the default presentation
scheme, or you can completely alter the way your site’s content is displayed, giving it whatever
presentation you like.


A theme must always contain a style sheet file called style.css. This file usually holds your basic
style. These PHP files are called template files. You’ll find index.php, which is the main file for
listings and search results and the fallback file for situations in which there is no other
template file available. Other common template files include sidebar.php, which holds the
sidebar content, comments.php for comment functionality, and header.php and footer.php
files for your site’s header and footer, respectively. You may also have single.php for single post
view, page.php for static WordPress pages, and maybe a dedicated template file for search
results (search.php), along with your category listings in category.php, and so on. Add any
number of page templates that you can apply to WordPress pages, and you get a tiny little
glimpse of how versatile WordPress is. Technically, your theme can consist of just a style.css
and an index.php file, but most themes have more template files than that.


With your template files, and the WordPress functions as well as plugins and traditional PHP
code, you can make your site behave in just about any way imaginable. Don’t want the
commenting capability at all? Just remove the code! Maybe you want a specific product page
to look completely different? Then create a page template and style it any way you like. It goes
on and on, and later in the book, you’ll see how to build sites that are nothing at all like the
common blog.


Just to make things a little more complicated, you can have even more functionality in your
themes. The functions.php file can provide plugin-like features to your theme, and just about
any template file can contain PHP code that does things beyond WordPress. I haven’t even

Free download pdf