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.
Notice: is_category was called incorrectlybut I don't seeis_categoryin your code. Please supply, probably,archive.phpessential part. – Max Yudin Feb 20 at 16:07archive.phpincludes only<?php get_header(); get_footer(); ?>– the notice is caused by the header.php code found above in my question – micadelli Feb 21 at 10:19