Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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.

share|improve this question
    
It says Notice: is_category was called incorrectly but I don't see is_category in your code. Please supply, probably, archive.php essential part. –  Max Yudin Feb 20 '13 at 16:07
    
@MaxYudin my archive.php doesn't actually matter, because it show the notice even when archive.php includes only <?php get_header(); get_footer(); ?> – the notice is caused by the header.php code found above in my question –  micadelli Feb 21 '13 at 10:19

1 Answer 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.

share|improve this answer
    
Hi, thanks for you input... but that doesn't make any difference. –  micadelli Feb 20 '13 at 13:55
    
In addition, the post_type parameter is with an underscore, not a hyphen. –  Johannes Pille Jul 27 '13 at 19:05
    
thanks @Johannes Pille, not sure how I missed it ;-) –  birgire Jul 27 '13 at 21:48

Your Answer

 
discard

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.