is_home() and is_front_page() not working in sidebar


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?

, , JP Lew 10 years 2013-08-23T22:48:39-05:00 0 Answers 96 views 0

Leave an answer