• Resolved donderhaas

    (@donderhaas)


    I am trying to use 8 widgets in different areas in my theme. I have registered the widgets in functions.php which look like this:

    <?php
    
    //register widgets
    register_sidebar(array('name'=>'Banners 1',
    	'before_widget' => '<div id="banners-1">',
    	'after_widget' => '</div>',
    	'before_title' => '',
    	'after_title' => '',
    ));
    
    //register widgets
    register_sidebar(array('name'=>'Sidebar 1',
    	'before_widget' => '<div id="sidebar-1">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3>',
    	'after_title' => '</h3>',
    ));
    
    register_sidebar(array('name'=>'Sidebar 2',
    	'before_widget' => '<div id="sidebar-2">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3>',
    	'after_title' => '</h3>',
    ));
    
    register_sidebar(array('name'=>'Sidebar 3',
    	'before_widget' => '<div id="sidebar-3">',
    	'after_widget' => '</div>',
    	'before_title' => '<div class="somediv"></div><h3>',
    	'after_title' => '</h3>',
    ));
    
    register_sidebar(array('name'=>'Footer 1',
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<h3>',
    	'after_title' => '</h3>',
    ));
    
    register_sidebar(array('name'=>'Footer 2',
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<h3>',
    	'after_title' => '</h3>',
    ));
    
    register_sidebar(array('name'=>'Footer 3',
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<h3>',
    	'after_title' => '</h3>',
    ));
    
    ?>

    Then in my pages I call these widgets one by one using:

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Banners 1') ) : ?><?php endif; ?> and specifying the names accordingly.

    Now the problem I have is that when I am in the admin area of my site I drag the widgets I want to use to the designated areas, but when I refresh or return to the widgets area later, my widgets have dissapeared or are in different widgets.

    For example: I set a recent post widget in sidebar 1, only to find it in sidebar 2 or 3 later.

    Am I registering my widgets incorrectly?

Viewing 1 replies (of 1 total)
  • Thread Starter donderhaas

    (@donderhaas)

    After implimenting my multiple widgets in the way described by Smashing Magazing it seems that my widgets are behaving now.

    The new code looks like this:

    register_sidebar( array(
    	'name' => 'Banners 1',
    	'id' => 'banners-1',
    	'before_widget' => '<div id="banners-1" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );
    register_sidebar( array(
    	'name' => 'Sidebar 1',
    	'id' => 'sidebar-1',
    	'before_widget' => '<div id="sidebar-1" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );
    register_sidebar( array(
    	'name' => 'Sidebar 2',
    	'id' => 'sidebar-2',
    	'before_widget' => '<div id="sidebar-2" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );
    register_sidebar( array(
    	'name' => 'Sidebar 3',
    	'id' => 'sidebar-3',
    	'before_widget' => '<div id="sidebar-3" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<div class="somediv"></div><h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );
    register_sidebar( array(
    	'name' => 'Footer 1',
    	'id' => 'footer-1',
    	'before_widget' => '<div id="footer-1" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );
    register_sidebar( array(
    	'name' => 'Footer 2',
    	'id' => 'footer-2',
    	'before_widget' => '<div id="footer-2" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );
    register_sidebar( array(
    	'name' => 'Footer 3',
    	'id' => 'footer-3',
    	'before_widget' => '<div id="footer-3" class="%2$s widget">',
    	'after_widget' => '</div>',
    	'before_title' => '<h3 class="widget-title">',
    	'after_title' => '</h3>'
    ) );

    Here is the article on SM https://www.smashingmagazine.com/2009/07/14/5-useful-and-creative-ways-to-use-wordpress-widgets/comment-page-1/

Viewing 1 replies (of 1 total)
  • The topic ‘Multiple Widget Problem’ is closed to new replies.