+ Reply to Thread
Results 1 to 2 of 2

Thread: Registering Sidebars

  1. #1
    Join Date
    Nov 2009
    Posts
    2

    Default Registering Sidebars

    Hi
    My site is www.sweetbirdclassics.org

    What I am trying to accomplish is to have a different sidebar on individual pages where I can exclude all but the subpages for that page so that my sidebars don't get too long.

    I am not well versed in code but after reading info here and in the wordpress codex, I copied sidebar.php and remaned it sidebar-2 and then made this attempt to register a sidebar named sidebar-2. It is not showing up on the when I try to edit widgets.

    function register_sidebars($number = 1, $args = array('name'=> 'sidebar-2','before_title'=>'<h1>','after_title'=>'</h1')) {
    global $wp_registered_sidebars;
    $number = (int) $number;

    Many thanks

  2. #2
    Join Date
    Feb 2009
    Posts
    605

    Default

    To register sidebars, try something like this:

    PHP Code:
    if ( function_exists('register_sidebar') )
        
    register_sidebar(array('name'=>'sidebar-1',
            
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
            
    'after_widget' => '</li>',
            
    'before_title' => '<h1 class="widgettitle">',
            
    'after_title' => '</h1>',
        ));
        
    register_sidebar(array('name'=>'sidebar-2',
            
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
            
    'after_widget' => '</li>',
            
    'before_title' => '<h1 class="widgettitle">',
            
    'after_title' => '</h1>',
        )); 


    The widget code should call the name of the sidebar in your file, e.g.:

    PHP Code:
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-2') ) : ?>
    (...stuff here...)
    <?php endif; ?>



    Quote Originally Posted by mehubbard View Post
    Hi
    My site is www.sweetbirdclassics.org

    What I am trying to accomplish is to have a different sidebar on individual pages where I can exclude all but the subpages for that page so that my sidebars don't get too long.

    I am not well versed in code but after reading info here and in the wordpress codex, I copied sidebar.php and remaned it sidebar-2 and then made this attempt to register a sidebar named sidebar-2. It is not showing up on the when I try to edit widgets.

    function register_sidebars($number = 1, $args = array('name'=> 'sidebar-2','before_title'=>'<h1>','after_title'=>'</h1')) {
    global $wp_registered_sidebars;
    $number = (int) $number;

    Many thanks

+ Reply to Thread

Similar Threads

  1. no sidebars on one page
    By nhlibrarian in forum Sidebar
    Replies: 6
    Last Post: 12-11-2009, 06:58 PM
  2. Comments count on Cutline 1.4 three column, split sidebars
    By koolvn in forum Posts, Pages, Comments
    Replies: 1
    Last Post: 03-30-2009, 09:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts