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 have a custom home page (home.php). I want to show the original home page's posts on /blog/.

I created a new blog.php file, with Template Name: Blog, added

query_posts('numberposts=5&paged=' . get_query_var('paged'));
require dirname(__FILE__) . '/index.php';

to the file.

The problem is that this query_posts call sets is_home() to true. I have some code in header.php that needs to be run only on the home page, but it runs on this template's pages too.

What's the best way to do this?

share|improve this question
up vote 1 down vote accepted

Don't do it this way. query_posts() should not be used most of the time and you are really hacking things up here with direct template inclusion and such.

  1. Create new page Blog (no template).
  2. Go to Settings > Reading.
  3. Assign this page as Posts page.
share|improve this answer
For some reason, this is making my Blog page show home.php. These are the settings I'm using: cl.ly/1t2W1j1z3p2i2q011G2R – Dogbert Mar 21 '12 at 15:48
@Dogbert home.php is template supposed to be used for list of posts that's why it picks it up. Use front-page.php for front page or do same thing with creating dedicated page for it and assign template to it. See Template Hierarchy in Codex. – Rarst Mar 21 '12 at 16:36
ah, got it. Thanks! – Dogbert Mar 21 '12 at 16:44

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.