• I have several templates pages(- each displaying posts from one different category) also each with a unique sidebar.

    BUT when each single post is displayed, the sidebar changes to defult. I want to be able to display each post with the sidebar category, page template it belongs to.

    Any pointer are welcome. Please Help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You have to register each new sidebar in your function.php file. Is it done ?

    I don’t think, so the system takes the default one.

    This can help you :
    This is a part of my function.php file

    /*
    #######################################
    Déclaration des sidebars et boites de Widgets WordPress
    #######################################
    */
    
    // Sidebar #1 par défaut
    if ( function_exists('register_sidebar') )
        register_sidebar();
    
    // Sidebar #2 (single.php)
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'Sidebar2 - single.php',
    'before_widget' => '<div id="sidebar"><ul><li>',
    'after_widget' => '</li></ul></div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',
    ));
    
    // Sidebar #3 (category.php et tag.php)
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'Sidebar3 - category.php et tag.php',
    'before_widget' => '<div id="sidebar"><ul><li>',
    'after_widget' => '</li></ul></div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',
    ));
    Thread Starter pixelrow

    (@pixelrow)

    Although I do have each unique sidebar registered. BUT … My template file has edited “Category” “recent Post” for each template file. Which are outside the dynamic widget bit. Hand coded.

    I am calling separate files like sidebar-topic, sidebar-translation etc.

    Thread Starter pixelrow

    (@pixelrow)

    Solved it my self:

    because the category was unique to each template so added this conditional code in the single post file.

    <?php

    if ( in_category(‘translations’) ) :
    get_sidebar(‘translations’);
    elseif ( is_404() ) :
    get_sidebar(‘404’);
    else :
    get_sidebar();
    endif;
    ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Uniqe Sidebars change to default with single post display’ is closed to new replies.