• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Navigation not showing up on category archive pages

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Navigation not showing up on category archive pages

This topic is: resolved

Tagged: categories, Custom Post Type, navigation

  • This topic has 7 replies, 3 voices, and was last updated 7 years, 7 months ago by asbilly92.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • January 9, 2015 at 4:22 pm #136794
    carrieoke13
    Participant

    For some reason, on my category archive pages, there is no navigation menu. Here's an example:

    http://eportfolio.uga.edu/wordpress/category/technological/

    I don't have a custom template for the archive pages. I do have a custom post type, but I'm not sure if that would cause an issue? The menu is showing on all other pages, on the custom post types, on the search results page, etc. I am totally stumped.

    I am using a heavily modified Foodie Pro theme.

    thanks for any help!

    January 10, 2015 at 6:15 am #136849
    Carlo
    Member

    Hi Carrie. That's definitely a strange result.

    You say that it's heavily modified. I took a look at the Foodie Pro demo and the menu does display on category archives, so it's not the way the theme is configured.

    I also noticed another strange difference between the demo and your site, and that is that the footer element on your site is 'popped out' of the site container.

    In other words, the markup structure in the theme demo is like this:

    <body>
    	<div class="site-container">
    		<header class="site-header"></header>
    		<nav class="nav-primary"></nav>
    		<div class="site-inner"></div>
    		<footer class="site-footer"></footer>
    	</div>
    </body>

    But on your site, it's like this:

    <body>
    	<div class="site-container">
    		<header class="site-header"></header>
    		<nav class="nav-primary"></nav>
    		<div class="site-inner"></div>
    	</div>
    	<footer class="site-footer"></footer>
    </body>

    Were you aware of that, or is that unexpected too?

    Based on that, I think it may be due to a coding error somewhere.

    I don't know if this will work, but try creating a new template called category.php and give it the following contents:

    <?php
    add_action( 'genesis_after_header', 'genesis_do_nav' );
    genesis();

    Comprehensive, easy to follow Genesis documentation

    January 11, 2015 at 12:51 pm #137072
    carrieoke13
    Participant

    Hi Carlos,
    I did that on purpose - I moved the footer out of the main container so it would be full width. I did that by adding this code to my functions.php:

    //* Reposition the footer widgets
    remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );
    add_action( 'genesis_after', 'genesis_footer_widget_areas' );
    
    //* Reposition the footer
    remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
    remove_action( 'genesis_footer', 'genesis_do_footer' );
    remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
    add_action( 'genesis_after', 'genesis_footer_markup_open', 11 );
    add_action( 'genesis_after', 'genesis_do_footer', 12 );
    add_action( 'genesis_after', 'genesis_footer_markup_close', 13 );
    

    I tried what you suggested and it's still not showing up. I'm wondering if something in my custom functions are making it disappear? This is so weird!

    January 11, 2015 at 1:02 pm #137083
    carrieoke13
    Participant

    Okay, I found the culprit, but I'm not sure how to edit it to fix the issue.

    This code adds my custom post types to tags and categories:

    //add custom post type to tags and categories
    function add_custom_types_to_tax( $query ) {
    if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
    
    // Get all your post types
    $post_types = array('post' , 'articles');
    
    $query->set( 'post_type', $post_types );
    return $query;
    }
    }
    add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

    When I comment it out, the menu reappears on my category archives, but all my custom post types that are in that category don't appear on the page anymore. Help!

    January 11, 2015 at 1:11 pm #137088
    carrieoke13
    Participant

    Okay! I have found a solution, and frankly, I have no idea why it works, but someone had another problem and posted about it in the comments here: http://premium.wpmudev.org/blog/add-custom-post-types-to-tags-and-categories-in-wordpress/#comment-153788

    Here's what I did: I replaced

    // Get all your post types
    $post_types = array('post' , 'articles');

    in the above code with

    
    $post_types = array( 'nav_menu_item','articles', 'news' );

    and magically, my menu is back!

    thanks so much for pointing me in the right direction!

    January 12, 2015 at 9:50 am #137175
    Carlo
    Member

    I see now. The reason your menu wouldn't show is because the function set the allowed post types to 'post' and 'articles'. The post type for menu items is 'nav_menu_item'. So all your menu items were blocked from showing.

    However, the code you've implemented now might still have some issues. Firstly, it's excluding 'post' and including 'news' (which you weren't doing before) and it also might cause your menu items to display in the main loop.

    I actually run very similar code on my own site, but I use $query->is_main_query() so that the post type manipulation runs for the main loop only and not the menu. You can use this code instead if you like:

    //add custom post type to tags and categories
    function add_custom_types_to_tax( $query ) {
    if( ( $query->is_category() || $query->is_tag() ) && $query->is_main_query() ) {
    
    // Get all your post types
    $post_types = array('post' , 'articles');
    
    $query->set( 'post_type', $post_types );
    }
    return $query;
    }
    add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

    Comprehensive, easy to follow Genesis documentation

    January 12, 2015 at 11:26 am #137202
    carrieoke13
    Participant

    Thank you, Carlo! This works beautifully.

    February 19, 2016 at 7:14 am #179384
    asbilly92
    Participant

    OMgosh!! I just have to say THANK YOU THANKS for this post thread!!

    I just had the exact issue, been struggling with it for 2 days; after finally getting my CPT's to show up in the archives then poof my nav menu went bye bye agggg, BUT this fixed it!!!

    Be lost without these forums!!

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Navigation not showing up on category archive pages’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble