Menu not appearing on a category archive page

Hey guys,

I’m having some trouble displaying a menu properly. It might just be my logic, so if this forum is not the right place, then please reply with ‘get lost’ and I will do so! But it is based on the roots theme :smile:

Basically, I have 2 CPTs. But I’m trying to add a menu to a non CPT archive (ie a normal blog post category page) in the sidebar.

What is happening however, is the sidebar for the CPT appears in the blog category sidebar. Here’s a snippet from my sidebar.php with the relevant code:

elseif ( is_tree('news-events') || is_archive( array('news', 'events') ) || is_singular( array('news', 'events') ) ) {

		if ( has_nav_menu('news_events') ) :
        	wp_nav_menu(array('theme_location' => 'news_events', 'menu_class' => 'news-events-nav'));

	} elseif ( is_blog() ) {
		echo "Hello";
		if ( has_nav_menu('blog_nav') ) :
        	wp_nav_menu(array('theme_location' => 'blog_nav', 'menu_class' => 'blog-nav'));

In my is_blog function, I have:

 * @return bool
function is_blog() {

    global $post;

    //Post type must be 'post'.
    $post_type = get_post_type($post);

    //Check all blog-related conditional tags, as well as the current post type, 
    //to determine if we're viewing a blog page.
    return (
        ( is_home() || is_archive() || is_category() || is_single() && ($post_type == 'post') )
    ) ? true : false ;


When I remove is_archive( array('news', 'events') ) || from my CPT menu logic in sidebar.php, the correct menu displays on the blog archive (but obviously breaks the CPT archive pages).

I have tried is_archive( array('news', 'events') ) && !is_archive('blog' || and even as a test is_archive( array('news', 'events') ) && !is_category('test' || (which of course represents the name of the category I have created).

The correct menu displays for a single blog post, and the main blog front page (I forget the correct term for this)… just not the category archive page.

If anyone can shed some light on this, then I would really really appreciate it!

FYI there: The site is here:
How the menu should appear on normal blog (single), category page, and blog home:

What is happening on the blog category pages:

Thanks in advance.

is_archive( array(‘news’, ‘events’) ) function call is wrong and causing problems.

this function doesn’t accept any parameters, what you need is:

is_post_type_archive( array(‘news’, ‘events’) )


Perfect! This solution worked for anyone interested