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 page called 'home' which is set to be the front of my site, but I'd like it to show the most recent blog post or two at the bottom. I have some PHP that will do this from another site

while (have_posts()): the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('Read the rest of this entry &raquo;'); ?>
<p><a href="<?php echo $siteroot .'/blog/' ?>">Go to the Blog...</a></p>
<?php endwhile; ?>

But I'm not sure where to put it in order to make it so it only shows on this one particular page since is_home() returns false for the page.

share|improve this question
up vote 1 down vote accepted

Since you are saying it's a "Page", I believe you should try is_page instead of is_home:

    if ( is_page( 'about' ) ) {    
         // Code to be shown on Page whose slug is "about"

OR for the way your code is, this should do:

<?php if ( is_page( 'about' ) ) { ?>
    <!-- Code to be shown on Page whose slug is "about" -->
<?php } ?>
share|improve this answer
perfect! thank you :) – Damon Jul 2 '12 at 2:32
@Damon then you should "mark" it as the answer :) – its_me Jul 2 '12 at 2:37
word dawg, but it makes me wait 10 minutes ;) – Damon Jul 2 '12 at 2:45

You can display code on a page set as the front page of your site using 'is_front_page' instead of 'is_home'. Any page set as the front page under Settings->Reading->Front page displays will then show the content within the query, instead of relying on a specific page slug.


share|improve this answer

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.