Different sidebar shown on different pages (2 posts)

  1. Eric
    Posted 8 years ago #


    I am trying to get WordPress to display a sidebar on single posts, and a different sidebar everywhere else on the site. If one of the sidebars has no widgets, I want it to go to the default sidebar configuration.

    Currently my sidebar.php file has:
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

    and I'm trying to make it into:
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
    when on a single post.

    I've tried many things, but I can't seem to get it to work right. So far my code looks something like:

    <?php if (is_single()) {
    if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else :
    } else (if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else :
    <li><h2><?php _e('Categories'); ?></h2>
    	<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=1'); ?>
    <?php endif; ?>

    But this doesn't seem to work! Any help will be appreciated.

  2. Eric
    Posted 8 years ago #

    Also i've done already modified my functions.php file accordingly.

Topic Closed

This topic has been closed to new replies.

About this Topic