• ladycrow

    (@ladycrow)


    Hi all. I’ve been successfully running multiple widgetized sidebars on my site for some time (https://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”

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ladycrow

    (@ladycrow)

    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();
    
    }
    ?>
    Thread Starter ladycrow

    (@ladycrow)

    I just thought I’d update this with a related find. This blog post has an even cleaner method of calling multiple sidebars: https://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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Smart Multiple Sidebars’ is closed to new replies.