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 trying to display a custom widget in the sidebar of my homepage (which is a static front page defined in Settings > Reading). Here is the relevant part of my sidebar.php:

if ( is_front_page() || is_home() ) {
    if ( is_active_sidebar( 'sidebar_lecture' ) ) : ?>
        <div id="secondary" class="widget-area" role="complementary">
            <?php dynamic_sidebar( 'sidebar_lecture' ); ?>

The sidebar does not display because the conditional tag does not recognize my homepage as being a homepage.

When I print_r($wp_query) in the sidebar, it reveals that [is_page] => 1 and that the post's [ID] => 32, which is correct. However, [is_home] is null.

For the record, I did use a custom query (query_posts()) in my page.php template, but I did reset it afterwards using wp_reset_query().

Any pointers?

share|improve this question
is_home being null on a static front page is correct, is_front_page is the one you should be looking at. also, query_posts should never be used, use WP_Query instead and polluting the global query object will be a non-issue. – Milo Aug 24 '13 at 4:22
Put a exit( 'working' ); right after if ( is_front_page() || is_home() ) { to make sure the issue isn't with your sidebar...So do this if ( is_front_page() || is_home() ) { exit('working'); } to test... – user23654 Aug 24 '13 at 4:31
@Milo & @splashingpixels: thanks for the tips, problem solved. You are correct, is_front_page() is matching correctly. I was confused because when I print_r($wp_query), is_front_page does not even show up as a property, while all the rest of the conditional tags are there. If it's not in the WP_Query object, then where is the "is_front_page" flag set? – JP Lew Aug 24 '13 at 4:42
and if one of you wants credit for the answer, add an answer and I'll mark it. – JP Lew Aug 24 '13 at 4:43
@Milo: won't adding a new WP_Query object reduce the page-load speed? My assumption was that simply modifying the existing query would yield better performance than running a separate query. – JP Lew Aug 24 '13 at 4:46

Your Answer


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

Browse other questions tagged or ask your own question.