Primary navigation menu & footer not showing in category / tag page

I tried to find a solution for primary navigation not showing in some pages, ie. archive.php.

I found one from here but it’s still giving me notices.

Read More

I’m using Reverie Theme in WordPress 3.6-alpha-23288

This is my code after implementing the fix

Plugins/MyMainPlugin.php

add_filter( 'getMainMenu',  array( $this, 'getMainMenu'),           10, 1);
function getMainMenu( $menuLocation ) {
    $locations          = get_nav_menu_locations();

    if ( empty( $menuLocation ) ) {
        $menuLocation   = 'primary_navigation';
    }

    $menuItems          = wp_get_nav_menu_items( $locations[ $menuLocation ] );
    if ( empty( $menuItems ) ) {
        return false;
    } else {
        wp_nav_menu( array(
            'theme_location'    => $menuLocation,
            'container'         => false,
            'menu_class'        => '',
            'echo'              => true,
            'before'            => '',
            'after'             => '',
            'link_before'       => '',
            'link_after'        => '',
            'depth'             => 0,
            'items_wrap'        => '<ul class="nav-bar">%3$s</ul>',
            'walker'            => new reverie_walker() ) );
        return true;
    }
}

Theme/header.php

if ( !apply_filters( 'getMainMenu', 'primary_navigation' ) ) {
    $backup     = $wp_query;
    $wp_query   = NULL;
    $wp_query   = new WP_Query( array( 'post-type' => 'post' ) );
    apply_filters( 'getMainMenu', 'primary_navigation' );
    $wp_query   = $backup;
}

Notices

Notice: is_category was called incorrectly. Conditional query tags do
not work before the query is run. Before then, they always return
false. Please see Debugging in WordPress for more information. (This
message was added in version 3.1.) in
/var/www/customers/xxx/public_html/wp-includes/functions.php
on line 2981 Notice: is_tag was called incorrectly. Conditional query
tags do not work before the query is run. Before then, they always
return false. Please see Debugging in WordPress for more information.
(This message was added in version 3.1.) in
/var/www/customers/xxx/public_html/wp-includes/functions.php
on line 2981

Any ideas how to solve this, and might be causing this? I have no idea what’s causing that.

Update
This actually affects to footer as well. So, I don’t see any footer on my archive.php page either.

Related posts

Leave a Reply

1 comment

  1. This line looks strange:

    $wp_query   = new WP_Query( array( 'post-type' => 'post','page' ) );
    

    you should try instead:

    $wp_query   = new WP_Query( array( 'post_type' => array('post','page') ) );
    

    ps: thanks to @Johannes Pille for the post_type correction.