WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] adding widgets to sidebar.php disables page specific sidebars (5 posts)

  1. rwwood
    Member
    Posted 1 year ago #

    If I use the admin interface to add widgets to the default sidebar.php, all my other page specific sidebars are disabled and use only sidebar.php. If all widgets are removed from the default sidebar, the other sidebars (category and single) work as expected.

    I'm not sure where to start to look for the problem.

    Thanks

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    I'm not sure where to start to look for the problem.

    for instance in sidebar.php ?

    http://codex.wordpress.org/Function_Reference/dynamic_sidebar

  3. rwwood
    Member
    Posted 1 year ago #

    I've read over and tried everything there and related, however I think the problem is related to the fact that I originally combined some of the twenty ten theme with another (Chocotheme).

    This is what I have in the top of the sidebar.php and functions.php

    <div id="sidebar">
    	<ul>
    		<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    			<li>
    				<?php get_search_form(); ?>
    			</li>
    
    			<?php if ( is_404() || is_category() || is_day() || is_month() ||
    						is_year() || is_search() || is_paged() ) {
    			?> <li class="metaplace">
    
    etc.
    function rww_widgets_init() {
    	// Default Sidebar.
    register_sidebar(array(
        'name' => 'sidebar',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
    
    	// Category Sidebar.
    register_sidebar(array(
        'name' => 'sidebar-category-sidebar',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
    
    	// Single Post Sidebar.
    register_sidebar(array(
        'name' => 'sidebar-single',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
    }
    /** Register sidebars by running rww_widgets_init() on the widgets_init hook. */
    add_action( 'widgets_init', 'rww_widgets_init' );

    Not sure that helps.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    in sidebar.php, everything from:

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

    to the corresponding

    <?php endif; ?>

    will not get executed if any widgets are used.

  5. rwwood
    Member
    Posted 1 year ago #

    I figured out the problems from this post and made the corrections.

    Thanks for you suggestions.

Topic Closed

This topic has been closed to new replies.

About this Topic