Need help displaying custom sidebar & custom menu automatically

Community Forums Forums Design Tips and Tricks Need help displaying custom sidebar & custom menu automatically

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  AC 1 year, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6902

    sonjay
    Participant

    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

    #6909

    AC
    Blocked
    Post count: 7712

    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.

    #7168

    sonjay
    Participant

    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();
    }
    }

    #7169

    AC
    Blocked
    Post count: 7712

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

    #7170

    sonjay
    Participant

    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?)

    #7171

    AC
    Blocked
    Post count: 7712

    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!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.