WordPress.org

Ready to get started?Download WordPress

Forums

Smart Multiple Sidebars (3 posts)

  1. ladycrow
    Member
    Posted 4 years ago #

    Hi all. I've been successfully running multiple widgetized sidebars on my site for some time (http://7and1.net). Each section has its own sidebar but I think the way I've been doing it is a bit clunky. Each section has its own page template and sidebar file. Is there I can edit and only use sidebar.php to show the correct sidebar for a page and all its children? Essentially, I was to say "if page is X or parent is X show sidebar Y"

  2. ladycrow
    Member
    Posted 4 years ago #

    Good news. I've figured out how to do this minus separate template files by adding this to my page.php. I would still love to be able to do away with the separate sidebar files altogether to further simplify so thoughts are welcome!

    <?php
    
    if ( is_page('Me') || $post->post_parent == '2168') {
    
       get_sidebar('me');
    
    } elseif (is_page('Content') || $post->post_parent == '2175')  {
    
       get_sidebar('content');
    
    } elseif (is_page('Site') || $post->post_parent == '2172') {
    
       get_sidebar('site');
    
    } elseif (is_page('Links') || $post->post_parent == '2965') {
    
       get_sidebar('links');
    
    } else {
    
       get_sidebar();
    
    }
    ?>
  3. ladycrow
    Member
    Posted 4 years ago #

    I just thought I'd update this with a related find. This blog post has an even cleaner method of calling multiple sidebars: http://marstonstudio.com/2007/07/17/multiple-wordpress-widget-sidebars

    I no longer have multiple sidebar files in my theme directory but I am still interested in a smarter/neater way of doing this.

Topic Closed

This topic has been closed to new replies.

About this Topic