Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've created my wordpress theme from the default Twenty Eleven theme, and I want to show a different sidebar on a few pages. I found this tutorial but it really doesn't answer my question.

So, I need a sidebar that is shown on admin panel at widgets page, and it should be at left side of the page.

share|improve this question

4 Answers 4

First add this following function to your functions.php,

function my_widgets_init() {
    register_sidebar( array(
        'name'      => __( 'Custom Sidebar Widgets' ),
        'id'        => 'custom-sidebar-widgets',
        'before_widget' => '<div id="%1$s" class="widget sidebar-widget custom-sidebar-widgets %2$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h3 class="widgettitle">',
        'after_title'   => '</h3>',
    ) );
}
add_action( 'widgets_init', 'my_widgets_init', 11 );

Add this code where you want to fetch custom sidebar,

<!-- begin custom sidebar -->
<div id="custom-sidebar">
<ul>
     <?php 
    if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( 'custom-sidebar-widgets' ) ) {
        /* Custom code if dynamic_sidebar not found */
    } ?>
  </ul>
</div>
<!-- end sidebar2 -->

This code works fine to me.

share|improve this answer
1  
function_exists( 'dynamic_sidebar' ) is not necessary. –  toscho Oct 25 '13 at 10:35

May not be a great, super awesome solution, but I just came across WooDojo by WooThemes. It's like Jetpack by WordPress.com plugin.

WooSidebars is a part of WooDojo plugin suite. You can download the plugin here (I think it requires WooDojo pre-installed).

What it does...

With WooSidebars you can override any widgetized area on your WordPress-powered website, displaying different widgets for different screens (a page, a category or search results, for example) without touching a line of code.

  • No theme modification required

  • Seemless WordPress Integration

  • Custom Sidebars for Any Post

  • Override any dynamic sidebar

  • Advanced Replacement Conditions (different widgets on different pages)

I am only suggesting this plugin because you can be sure that the plugin won't be abandoned like most on WP.org, and the code is not bad at all.

share|improve this answer

You could create a page template that calls the sidebar you want like Joseph mentioned. That way you can select which template to use depending on which sidebar is right for the page.

Creating Page Templates

Adding Widget areas will show you how to widgetize the sidebar.

share|improve this answer

Have a look at the Codex page for get_sidebar(). In particular, the section that mentions calling sidebars with other names and the multiple sidebar section.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.