WordPress.org

Support

Support » How-To and Troubleshooting » Create a different sidebar, how?

Create a different sidebar, how?

  • Hi. At this moment I got a sidebar displaying the default widgets (search, categories, archives, etc.), but If I want to create a different sidebar showing advertisement only, how should I proceed for that?

    Thanks!

Viewing 1 replies (of 1 total)
  • you can either add another widget to that sidebar, or register another sidebar in your functions.php
    This is how to register sidebar:

    //Widget-enabled sidebar
    if ( function_exists('register_sidebar') )
        register_sidebar(array('name'=>'sidebar1',
            'before_widget' => '<div class="sidebar1">',
            'after_widget' => '</div>',
            'before_title' => '<div class="title">',
            'after_title' => '</div>',
        ));

    and this is what should be in your sidebar.php

    <div class="sidebar">
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('sidebar1') ) : ?>
    <?php endif; ?>
    </div>

    and you call it in your page.php, single.php, or wherever you want it

    <?php get_sidebar()?>

Viewing 1 replies (of 1 total)
  • The topic ‘Create a different sidebar, how?’ is closed to new replies.