WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm confused by the template hierarchy in WordPress. I have front-page.php in a theme I'm developing. It looks great and it works, but then when a user clicks 'Older Posts', it just shows the same content as before, but the URL is changed to ?paged=2.

Looking at the diagram about Template Hierarchy on Wordpress Codex, since the second page is not the front page, I'd expect it to fall through front-page.php to either home.php or index.php, but it's not doing that; it's just loading front-page.php over and over again.

So how can I load, say index.php, for every page other than the front page?

And also, am I crazy for expecting what I expect?

The second question might be subjective. Please only answer the first if you think I am crazy.

share|improve this question
up vote 1 down vote accepted

Pagination does not affect the template usually, paged.php is the exception but not of interest for your question.

To style the first page differently than later pages check for

if ( is_front_page() and 1 < get_query_var( 'paged' ) ) 
    // code for later pages
share|improve this answer
That's...rather hacky. I'd really like to have my "lists of posts" pages to look the same regardless where they are in the site. I.e. working off the same template. Doing what you suggest means the same code is in two spots. Yuck. Is there no other way? – ageektrapped Oct 26 '12 at 0:41
@ageektrapped - use a template part for code reuse. – Milo Oct 26 '12 at 3:21
Thanks @Milo. I used your suggestion combined with toscho's to get what I wanted. Still think it's weird, but can't do much about it. – ageektrapped Oct 26 '12 at 13:31
@ageektrapped - you may also want to check out the template filters, which will let you force specific templates under your own conditions. look in wp-includes/template-loader.php and wp-includes/template.php to see how WordPress selects a template, and the apply_filters calls for each where you could add your own filter function to manipulate it. – Milo Oct 26 '12 at 17:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.