Cleaning Out the Template

The first step in creating this sort of custom home page is to find the template you
want and prepare it for editing. In virtually all modern themes, the index.php template
is the one you want. It creates a home page with the standard list of posts. (The
only exception is if your theme has a home.php file—if it does, edit that template
instead.) To get started, choose Appearance→Editor and then pick “Main Index
Template (index.php).”
In many ways, the index.php template is like the category.php template you considered
in the first part of this chapter. The heart of both is a loop that extracts and
displays posts. The most significant difference is that category.php uses a narrower
query that includes the posts in just a single category.
You could keep the standard loop in the index.php template and simply change the
way it displays each post. You’ve seen examples that use this technique to highlight
new posts  and change the post order. But here makes
a more radical change—it grabs several separate post lists, by category, and then
displays them. The easiest way to make this happen is to remove the existing loop
entirely and add all new code. In most themes, that means deleting everything
inside the content <div>.
In the PinBlack theme, deleting the loop leaves you with this exceedingly simple
skeleton:

<?php get_header(); ?>
<div id=”content” class=”clearfix”>
</div> <!– end #content –>
<?php get_footer(); ?>

All this template does is add a header and footer to a page. In between is a great
big empty section where you can slot in your own content.

NOTE Remember, the header template (header.php) isn’t just a header—it has the HTML markup that begins
each page, which includes the title, style sheet links, background, and menu. Similarly, the footer template (footer.
php) includes the HTML that ends every page. So even in a simple stripped-down template like the one shown
above, your site ends up with a fully formatted home page, albeit one that doesn’t have any content in it.

Advertisements
Cleaning Out the Template

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s