WordPress.org

Ready to get started?Download WordPress

Forums

Create a different sidebar, how? (2 posts)

  1. hildergarn
    Member
    Posted 2 years ago #

    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!

  2. zex2911
    Member
    Posted 2 years ago #

    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()?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags