• Resolved nmhall

    (@nmhall)


    I’ve noticed that the theme hides the nav menu (topbar) on Category pages. Is there a workaround that fixes this issue easily?

    I don’t see anything in header.php that would prevent it from showing on category pages:

    <?php if ( has_nav_menu('topbar') ): ?>
    	<nav class="nav-container group" id="nav-topbar">
    	<div class="nav-toggle"><i class="fa fa-bars"></i></div>
    	<div class="nav-text"><!-- put your mobile menu text here --></div>
    	<div class="nav-wrap container"><?php wp_nav_menu(array('theme_location'=>'topbar','menu_class'=>'nav container-inner group','container'=>'','menu_id' => '','fallback_cb'=> false)); ?></div>

    Since there’s not a category.php page, I’m assuming that it’s failing back to archive.php. In archive.php there also doesn’t appear to be anything that would cause the nav to disappear.

    Thanks for any help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nmhall

    (@nmhall)

    Digging into the functions.php, I’m guessing that it has something to do with the built in Option Tree, specifically this part:

    // Set layout based on page
    		elseif ( is_home() && ( ot_get_option('layout-home') !='inherit' ) ) $layout = ot_get_option('layout-home',''.$default.'');
    		elseif ( is_category() && ( ot_get_option('layout-archive-category') !='inherit' ) ) $layout = ot_get_option('layout-archive-category',''.$default.'');
    		elseif ( is_archive() && ( ot_get_option('layout-archive') !='inherit' ) ) $layout = ot_get_option('layout-archive',''.$default.'');
    		elseif ( is_search() && ( ot_get_option('layout-search') !='inherit' ) ) $layout = ot_get_option('layout-search',''.$default.'');
    		elseif ( is_404() && ( ot_get_option('layout-404') !='inherit' ) ) $layout = ot_get_option('layout-404',''.$default.'');

    I don’t know enough about ot_get_option to figure out what’s going on with layout-archive-category or how to change it though…

    Thread Starter nmhall

    (@nmhall)

    I guess I’ll just keep documenting in case anyone else encounters this problem. I eventually discovered that it’s not an issue with Option Tree (as I was investigating earlier).
    It appears to be a conflict in a function that I put in the child theme. If you use create_post_type as a function for making custom post types, then you’ve probably also had to include a function called query_post_type to make those posts show up on their own archive pages. The problem is that this method makes the nav menu disappear on category.php or archive.php. To fix the problem you need to add nav_menu_item to query_post_type, like so:

    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','calendar');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    If you need more info, this is where I eventually found the solution. Thanks to boyvanamstel for this github thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Nav menu not appearing on category pages’ is closed to new replies.