• 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

Need help displaying custom sidebar & custom menu automatically

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 › Need help displaying custom sidebar & custom menu automatically

This topic is: not resolved

Tagged: custom menu, custom sidebar

  • This topic has 5 replies, 2 voices, and was last updated 10 years, 3 months ago by Anita.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • December 22, 2012 at 5:28 am #6902
    sonjay
    Member

    I have a multisite install, with all sites using the Lifestyle child theme. I've used Genesis Simple Sidebars to create a second alternative primary sidebar, and the Menus option to create an alternative menu for the "secondary navigation" menu area.

    What I want:

    The home page and every "page" (not post) should use the main primary sidebar and original secondary navigation menu, but every post and post category should use the alternative primary sidebar and alternative secondary navigation menu. Basically, the entire "blog" section of the site should have a different primary sidebar and nav menu from the home page and all other pages on the site.

    It's easy enough to assign the appropriate sidebar and menu for each category and each post. But I'd prefer to have that happen automagically. This multisite install will have multiple different people working on it, some of whom will be less... shall we say .... computer-savvy than others. I want to reduce to an absolute minimum the things that they have to do when posting a new blog post or creating a new category.

    Since the requirement is consistent across all sites in the multisite install, and consistent in that I always want Sidebar A and Menu A to be displayed on the home page and each "page," and Sidebar B and Menu B to be displayed on each post and post category, I'm guessing there should be something I can stick in the functions.php file using conditional logic along the lines of "if ( is_home or is_page) { Sidebar A & Menu A  } elseif ( is_post or is_category ) {Sidebar B & Menu B}

    Here is the site that I'm using as a testbed for this approach:

    http://withblog.suncoasteam.com/

    Here is the blog section, with a different menu in the green gradient nav menu and a different primary sidebar:

    http://withblog.suncoasteam.com/blog

    December 22, 2012 at 6:49 am #6909
    Anita
    Keymaster

    Off the top of my head right now, I would suggest using Widget Logic to set that up - http://wordpress.org/extend/plugins/widget-logic/. Someone else may have a better way, but take a look at this.


    Love coffee, chocolate and my Bella!

    December 23, 2012 at 10:32 am #7168
    sonjay
    Member

    Thanks for the suggestion. That plugin probably would have accomplished what I needed for the sidebar, but not for the menu. But after looking at the code in the plugin, and doing some more reading in the genesis help files, I figured out what I needed. I'll post it here in case anyone else needs to do the same thing:

    For the custom sidebar, I copied the sidebar.php file from the genesis directory to my Lifestyle theme directory, and stuck this code in my sidebar.php file, replacing the line "do_action( 'genesis_sidebar' );"

    if ( is_single() || is_archive() || is_page('blog') ) {
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    add_action( 'genesis_sidebar', 'my_genesis_do_blog_sidebar' );
    function my_genesis_do_blog_sidebar() {
    dynamic_sidebar( 'blogsidebar' );
    }
    do_action('genesis_sidebar');
    } else {
    do_action( 'genesis_sidebar' );
    }
    }

    For the menu, I stuck this in my functions.php file:


    remove_action('genesis_after_header', 'genesis_do_subnav');
    add_action('genesis_after_header','my_custom_subnav');
    function my_custom_subnav () {
    if ( is_single() || is_archive()  ) {
    echo '<div id="subnav"><div>';
    wp_nav_menu( array('menu' => 'TopGreenBarForBlogSection' ));
    echo '</div></div>';
    } else {
    genesis_do_subnav();
    }
    }

    December 23, 2012 at 10:36 am #7169
    Anita
    Keymaster

    That's great. It's like a recipe.. just need the right ingredients to make it work.


    Love coffee, chocolate and my Bella!

    December 23, 2012 at 10:49 am #7170
    sonjay
    Member

    Except, sorry, bits of the code got transformed -- you'll have to mentally change all those &lg; and > bits into

    (hope the same thing doesn't happen again. if it does, you'll have to be smart enough to just know what I mean)

    (and why isn't there a preview in this forum, so that I can at least see if things are correct before hitting Submit?)

    December 23, 2012 at 10:51 am #7171
    Anita
    Keymaster

    I don't don't know. I had the problem copying code the other day and it was really screwing up the person I was trying to help. I wish this would work right. I'll remember your instructions!


    Love coffee, chocolate and my Bella!

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and 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