Forums

How to have different sidebars on different pages? (9 posts)

  1. leighangela
    Member
    Posted 1 year ago #

    Please tell me how to have a main sidebar, but use another sidebar with different widgets for my blog page. Thanks!!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You would need to create 1 or more new, widget-ready, sidebar template files. Then, assuming you're using a static front page, use get_sidebar to call one of them in your front page's template file and another in your index.php file for your blog page.

  3. leighangela
    Member
    Posted 1 year ago #

    Are there steps detailing what you're telling me to do? I appreciate you saying "create a new sidebar template file," but how?

    thanks.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You need to examine your current theme's sidebar.php template file and use that as a foundation for your new sidebar. It helps if you're comfortable using PHP, XHTML and WordPress tags but you could start by simply copying your current sidebar.php file and saving the copy as sidebar-alt.php.

    Then it will be a case of removing what you don't want from the new file and adding in the bits that you do want - which can be done on a step by step basis.

  5. leighangela
    Member
    Posted 1 year ago #

    I see! So, does this mean the widgets in the alternate sidebar won't have the simple drag and drop ability of the original sidebar? Or will the alternate sidebar show up on the widgets page too?

    thanks a lot.

  6. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    If you want the the new sidebar to be widget-capable, it will mean tweaking some the copied code in your new sidebar and making a small addition to your theme's functions.php file. The new sidebar will then accept widgets completely independently from your current sidebar.

  7. leighangela
    Member
    Posted 1 year ago #

    I see. Do you happen to know the specifics? I appreciate your help.

  8. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    The specifics vary with every single theme.

  9. mdbitz
    Member
    Posted 1 year ago #

    Hi:

    Basically Sidebar Widgets are inserted through the following method that can be found in the theme's template files.
    dynamic_sidebar( 'secondary-widget-area' );
    Where the value passed is the name of the sidebar.

    To be able to use the WordPress Widget Admin to drag-n-drop widgets to your named sidebars you will need to register them in your theme's functions.php file.

    Example:

    register_sidebar(
        array(
            'name' => __( 'Secondary Widget Area', 'twentyten' ),
            'id' => 'secondary-widget-area',
            'description' => __( 'The secondary widget area', 'twentyten'
        ),
        'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
     ) );

    You should be able to search the functions file and copy the existing registration and change the name to your newly created one and you should be all set.

    Hope this helps you out.

Topic Closed

This topic has been closed to new replies.

About this Topic