0
votes

Good day. In WordPress via Settings -> Reading, I updated the page my posts get output (see screen shot). New page is called Blog. It's parent page is News.

Posts are displaying fine, however, for the Blog page, is_home() is now true!?!. It's URL is unchanged (/news/blog).

A little background: Under the hood I sniff each page to determine what sub nav to display. Since the posts page thinks it's the home page, no sub nav is output, which is not correct.

Why it would lose it's true parent and think that it's the home page now? Is this by design? Any way around this?

WordPress version:3.1 / Theme: Starkers

Thanks.

WordPress Reading Settings

1

1 Answers

1
votes

This behavior is normal and causes a lot of confusion. You can either add a special case to the code for your subnav based on the is_home() conditional, or you can create a custom page template that includes a secondary query using WP_Query to pull in recent posts.

Here is a skeleton for the secondary query:

<?php $secondary_query = new WP_Query(array('post_type' => 'post')); ?>
<?php if($secondary_query->have_posts()): ?>
    <?php while($secondary_query->have_posts()): ?>
        <?php $secondary_query->the_post(); ?>
        <?php // normal query stuff like the_title() and the_content() ?>
<?php endwhile; endif;?>
<?php wp_reset_postdata(); ?>