Different sidebar for posts in specific category

Community Forums Forums Design Tips and Tricks Different sidebar for posts in specific category

This topic is: not resolved

This topic contains 7 replies, has 5 voices, and was last updated by  jvandevorst 1 year, 4 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #24219

    jvandevorst
    Participant
    Post count: 3

    I want to display a specific sidebar only for posts which are in a certain category. For example for posts that are “property listings” I want to display a certain sidebar. This is for the post page not the archive.

    I have tried this in functions.php but can’t get it to work:

    if (in_category(8)) {

    remove_action( ‘genesis_after_content’, ‘genesis_get_sidebar’ );
    add_action( ‘genesis_after_content’, ‘child_switch_sidebar’ );
    function child_switch_sidebar(){
    echo ‘<div id=”sidebar” class=”sidebar widget-area”>’;
    dynamic_sidebar(‘listing-detail-sidebar’);
    echo ‘</div>’;
    }
    }

    #24221

    Susan
    Moderator
    Post count: 7988

    Have you considered the Simple Sidebars plugin? It makes it easier to add sidebars on a post or page basis”
    http://www.studiopress.com/plugins/simple-sidebars


    Susan @ Graphically Designing I’d love to customize your website! I tweet!
    I’ve taken up the challenge! – help me answer some of the unanswered posts

    #24227

    jvandevorst
    Participant
    Post count: 3

    Hi Susan,

    I should have mentioned that these posts are being created automatically by importing a feed. If I were creating them manually I agree that it Simple Sidebars would be a simple solution…no pun intended.  I need an automatic way for the post category to be recognized and then the right sidebar to be displayed.  BTW the sidebar was created using Simple Sidebars plugin.

    #24231

    anitac
    Participant
    Post count: 7027

    Using Simple Sidebars…. if you go to Categories, and select a Category to edit – scroll down and you can allocate one of your simple sidebars to the category you created.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #24232

    Kraft
    Participant
    Post count: 86

    well, the code got mangled and the above solution is easier, so I’ll let this post slide. :-)


    Brandon Kraft
    Volunteer
    Blog | Twitter | Business
    Genesis eNews Extended Support

    #24234

    jvandevorst
    Participant
    Post count: 3

    @anitac. Thanks for the suggestion.  Unfortunately that only changes the sidebar for the category/archive page but not the actual post page.

    Im trying to change the sidebar for the post Not the archive/category page.

    #24240

    thewebprincess
    Participant
    Post count: 10

    Does Simple Sidebars work with Dynamic Widgets?  DW is a pretty comprehensive free plugin that allows you to get really down to the nitty gritty of which widgets show up where.  It removes the need for multiple sidebars as it’s working on the individual widgets themselves.  Might be worth checking out

    #24241

    jvandevorst
    Participant
    Post count: 3

    @thewebprincess. I will check that out thanks.

     

     

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

You must be logged in to reply to this topic.