• Resolved mkreidler

    (@mkreidler)


    [ Moderator note: moved to Fixing WordPress. Please do not use Developing With WordPress for these topics. ]

    My site at https://qweencity.com/ has a menu that I set to look like a mobile menu at all screen sizes. It works well on all pages except for category archive ones. Even other archive pages work just fine. Here is an example of a page where the menu doesn’t work: https://qweencity.com/category/performance/

    I couldn’t find much info about this problem while googling (especially since it was also inundated with general info about adding menus on certain pages) so I’m not sure where to start on fixing this. Any help or ideas are appreciated!

Viewing 10 replies - 1 through 10 (of 10 total)
  • May be because your theme allows you to add a different menu for the category archive and you didn’t create or set it on you dashboard.

    Thread Starter mkreidler

    (@mkreidler)

    That’s a good thought. But my theme is a child theme of Bootstrap Basic and by default it only supports one menu. I didn’t add another one in the functions file. I also have WP-DEBUG on and have no errors on those pages.

    The menus that don’t work have blank space between the <div> tags with class “collapse navbar-collapse navbar-primary-collapse” vs menus that do with with the list of the menu.

    It seems that the ul element for navbar not generated.
    This happens on every category/ pages but not tag/ pages.

    I’m not sure how you write the template for category page. Did you render the menu in there and how?

    Thread Starter mkreidler

    (@mkreidler)

    It’s just using the header.php file like all the rest and I didn’t create any specific archive page just for categories, so it uses archive.php just like the rest.

    Yes, it is really strange. See my theme on demo website. https://product-demo.rundiz.com/wordpress/
    The menu is still working on every pages.

    Do you have something like is_category() in the archive.php, header.php?
    Please make sure that you did not conditional anything before render the menu.

    Thread Starter mkreidler

    (@mkreidler)

    No conditionals in the header.php file. I even simplified the wp_nav_menu() function to take away Bootstap Basic’s walker function in case the problem was there, but even the very basic: <?php wp_nav_menu(array('theme_location' => 'primary', 'container' => false, 'menu_class' => 'nav navbar-nav')); ?> code doesn’t show up.

    The only conditional in the archive page is for the title above the posts.

    OK, just WP nav menu still not working. No conditionals for nav menu.

    I use this BootstrapBasic for demo site and use it as parent theme for real site and both works fine. So, I can say that the theme itself should works fine in your case.

    May I ask you to try something more?
    I suggest to do it in your localhost to prevent any damage to real website.

    Please try to disable all the plugins fist and see is it works?
    If it still not works then try to comment all the code (php comment /*...code here...*/) in your theme that contain any hooks into WordPress such as add_filter(), add_action() and see is it works? ??

    • This reply was modified 7 years, 10 months ago by vee.
    Thread Starter mkreidler

    (@mkreidler)

    Thanks for this suggestion, this helped lead me to the offending code in my functions.php:

    function add_custom_types_to_tax( $query ) {
    		if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { 
    		$query->set( 'post_type', array('post', 'photo-essay') );
    		}
    }
    		add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

    Menu works fine when I comment it out. Any suggestions how I can get multiple post types to still show up on category and taxonomy pages without this code? Or is there an error in it we can fix?

    Thread Starter mkreidler

    (@mkreidler)

    And, I found the solution! Thanks everyone for your help:

    function namespace_add_custom_types( $query ) {
      if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'nav_menu_item', 'your-custom-post-type-here'
    		));
    	  return $query;
    	}
    }
    add_filter( 'pre_get_posts', 'namespace_add_custom_types' );

    Good to see all things fixed. ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Menu doesn’t open on Category Archive Pages’ is closed to new replies.