• Hi,
    I’ve been googling this but can’t find a solution.

    I have three menus registered in my function.php file:

    function register_theme_menus(){
    
       register_nav_menus(
    
          array(
    	      'main-menu' => __('Main Menu'),
    		  'work-menu' => __('Work Menu'),
    		  'categories-menu' => __('Categories Menu')
    
    	  )
       );
    }
    
    add_action( 'init', 'register_theme_menus');

    These are called into sidebar.php so share the same code:

    <?php wp_nav_menu( array( 'theme_location' => 'main-menu', 'menu_class' => 'mnnav worknav' ) ); ?>
     <h3 class="work hidden-xs">Work</h3>
    
    <?php wp_nav_menu( array( 'theme_location' => 'work-menu', 'menu_class' => 'mnnav hidden-xs' ) ); ?>
    
    <h3 class="work hidden-xs">Categories</h3>
    
    <?php wp_nav_menu( array( 'theme_location' => 'categories-menu', 'menu_class' => 'mnnav' ) ); ?>

    The menus show up fine on all the pages apart from category-slug pages.

    I’m using custom post types (portfolio).

    Any ideas what I’m doing wrong?

Viewing 1 replies (of 1 total)
  • Thread Starter fish333

    (@fish333)

    I fixed it.

    In case it helps someone else. I added the following in my functions.php file:

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if(is_category() || is_tag()) {
        $post_type = get_query_var('post_type');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('nav_menu_item','post','articles');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    I had all of the code apart from: ‘nav_menu_item’ added to the array.

Viewing 1 replies (of 1 total)
  • The topic ‘menu not displaying on category pages’ is closed to new replies.