Title: [Plugin: Multiple Sidebars] Bugs in method dynamic_sidebar()
Last modified: August 20, 2016

---

# [Plugin: Multiple Sidebars] Bugs in method dynamic_sidebar()

 *  Resolved [JochenT](https://wordpress.org/support/users/jochent/)
 * (@jochent)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/)
 * Hi,
 * Me again. I’ve found two bugs in method dynamic_sidebar() in code fragment
 *     ```
       $sidebars = explode(",", $sidebars);
       if(!$sidebars){
       	$sidebars = "multiple-sidebars-default";
       }
       foreach ($sidebars as $sidebar) {
       	if (is_active_sidebar($sidebar)) {
       		dynamic_sidebar($sidebar);
       	}
       }
       ```
   
 * One problem is the use of the function explode(). If $sidebars is an empty string
   it returns an none empty array which contains one empty element (`count($sidebars)
   ==1`). Thus the following if-statement `if(!$sidebars) { ... }` will always fail
   as the array is not empty. Finally the `foreach (...)` will loop and call function‘
   is_active_sidebar($sidebar)` with an empty string. This will always fail and 
   the default sidebar is never displayed as fallback.
 * The second problem is the definition of the array for the name of the default
   sidebar `$sidebars = "multiple-sidebars-default";`. The assignment of a string
   to a variable is not an array. You have to cast the string into an array before
   assignment `$sidebars = array("multiple-sidebars-default");`. But as this statement
   was never executed it had no effect on the code.
 * Together with my suggestion from the other post the modified code could be
 *     ```
       $sidebars = empty($sidebars) ? array('multiple-sidebars-default') : explode(',', $sidebars);
       foreach ($sidebars as $sidebar) {
       	if (is_active_sidebar($sidebar)) {
       		$success = dynamic_sidebar($sidebar) ? true : $success;
       	}
       }
       ```
   
 * [http://wordpress.org/extend/plugins/multiple-sidebars/](http://wordpress.org/extend/plugins/multiple-sidebars/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Andrico](https://wordpress.org/support/users/andrico/)
 * (@andrico)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618308)
 * perfect!
    and is implemented as I said!
 * very good correction!
 * I will put you among the contributors!
 * Sorry for the English, but use the google translator.
 *  Thread Starter [JochenT](https://wordpress.org/support/users/jochent/)
 * (@jochent)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618339)
 * Hi,
 * Thank you. This is much of honor. The good idea and most of the code is still
   from you. But I appreciate it.
 *  [trulygood](https://wordpress.org/support/users/trulygood/)
 * (@trulygood)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618464)
 * Hi I am attempting to use this Plugin/this code but despite having created the
   Sidebars, activated them, and assigning them to a page, nothing is being displayed.
 * Here is my sidebar template code:
 *     ```
       <?php
   
       	$sidebars = empty($sidebars) ? array('multiple-sidebars-default') : explode(',', $sidebars);
       foreach ($sidebars as $sidebar) {
       	if (is_active_sidebar($sidebar)) {
       		$success = dynamic_sidebar($sidebar) ? true : $success;
       	}
       } ?>
       ```
   
 * Am I missing something?
 * Cheers,
    Andy
 *  Thread Starter [JochenT](https://wordpress.org/support/users/jochent/)
 * (@jochent)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618465)
 * These changes are only for function dynamic_sidebar() in the plugin code. In 
   the current version of the plugin these changes are already implemented. You 
   have to do nothing if you use the latest version.
 *  [trulygood](https://wordpress.org/support/users/trulygood/)
 * (@trulygood)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618466)
 * I see. Well, doing nothing also did not work.
 * I tried to activate the sidebars using the Widget and that did nothing. I also
   tried to put the sidebar code as seen in the screenshot here ([http://s.wordpress.org/extend/plugins/multiple-sidebars/screenshot-3.jpg?r=548482](http://s.wordpress.org/extend/plugins/multiple-sidebars/screenshot-3.jpg?r=548482)),
   but that did not work.
 * What is the best way to get the Custom Sidebars I have created and activated 
   to show up in my theme?
 *  Thread Starter [JochenT](https://wordpress.org/support/users/jochent/)
 * (@jochent)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618467)
 * I use it in TwentyEleven the following way:
 *     ```
       <?php
       global $MultipleSidebars; // from plugin "Multiple Sidebars"
       $useFallbackSidebar = true;
       if ( method_exists( $MultipleSidebars, 'dynamic_sidebar' ) ) {
           if ($MultipleSidebars->dynamic_sidebar()) {
               $useFallbackSidebar = false;
           }
       }
       ?>
       <?php if ($useFallbackSidebar && !dynamic_sidebar('sidebar-1')) : // use wp core sidebar functions ?>
   
         // any basic fallback sidebar widgets
   
       <?php endif; ?>
       ```
   
 * See sidebar.php in theme TwentyEleven for details.
 *  [trulygood](https://wordpress.org/support/users/trulygood/)
 * (@trulygood)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618468)
 * Hi JochenT.
    Thanks for the reply, I appreciate it.
 * I am using a child theme for TwentyTen theme. I tried your code as is, but it
   did not work.
 * I then modified it so it used TwentyTen code, but that is not working either.
   I can typically figure out things like these, so this is frustrating.
 * Here is the code I am trying…
 *     ```
       <?php
       global $MultipleSidebars; // from plugin "Multiple Sidebars"
       $useFallbackSidebar = true;
       if ( method_exists( $MultipleSidebars, 'primary-widget-area' ) ) {
           if ($MultipleSidebars->primary-widget-area()) {
               $useFallbackSidebar = false;
           }
       }
       ?>
       <?php if ($useFallbackSidebar &&! dynamic_sidebar( 'primary-widget-area')) : // use wp core sidebar functions ?>
   
         // any basic fallback sidebar widgets
   
       <?php endif; ?>
       ```
   
 * Which is returning NOTHING at all, not even the “any basic fallback sidebar widgets”
   text
 * I have the MultipleSidebar widget placed in my Primary Sidebar, and my “Default
   Sidebar”.
 * Any thoughts?
 *  Thread Starter [JochenT](https://wordpress.org/support/users/jochent/)
 * (@jochent)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618469)
 * Sorry, you need knowledge in PHP to understand this. Perhaps you may ask a friend
   to help you.
 *  [trulygood](https://wordpress.org/support/users/trulygood/)
 * (@trulygood)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618470)
 * Hmmm..
    Is there no way to have the Plugin just work? Most Plugins I’ve ever 
   used work upon Activation. Sometimes I have to drop a line or 2 of code into 
   a template file. But I have never needed thorough php knowledge to make a Plugin
   work according to its default behaviour. That is why i am confused. I don’t think
   I am attempting to make the Plugin respond to any custom behaviour at all.
 * Let’s take it a step backwards.
    -I install and Activate the Plugin. -I create
   a custom Sidebar. -I activate the custom Sidebar in the Sidebars > Options menu-
   I assign it to a specific page by dragging it from Inactive to Active in that
   page screen -I drop the Multiple Sidebars Widget into my Primary Widget Area
 * Shouldn’t the custom Sidebar I created now be displayed on the Page I assigned
   it to? This is why I am confused. I follow basic instructions accordingly, but
   no Sidebar is displayed.
 * Any thoughts? Perhaps Plugin developer would know?
 *  Plugin Author [Andrico](https://wordpress.org/support/users/andrico/)
 * (@andrico)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618471)
 * Hello, trulygood!
 * It seems very strange that the plugin does not work that way.
 * I would say that you first uninstall the plugin, and follow the steps I mention
   below:
 * 1 – install the plugin
    2 – Activate the plugin 3 – place the widget “Multiple
   Sidebars” in the default template sidebar 4 – create a page, post or custom post
   type, and from the menu on the right side, create a sidebar and place in the 
   sector “active”.
 * I tried it and it worked. You might have a conflict with another plugin.
 * Sorry for the delay in answering, and for my English. I use google translate.
   😉
 * If the above does not work, follow the steps 1, 2, 4, and places in the area,
   removing all the template code that references dynamic_sidebar. (or override 
   it with ” /* OLD CODE */ “). and put in its place
 * <?php
 * global $MultipleSidebars;
    if ($MultipleSidebars -> dynamic_sidebar ()) { echo“
   No sidebars selected”; }
 * ?>
 * Good luck and hope it works and you solve a problem!
 *  [trulygood](https://wordpress.org/support/users/trulygood/)
 * (@trulygood)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618472)
 * Hi Andrico,
    Thanks very much for the response. I try both your suggestions, 
   and no results. There are no other Plugins installed and activated.
 * I tried with custom TwentyTen Child Theme, as well as TwentyTen itself. I even
   gave TwentyEleven a shot, no luck.
 * Perhaps you can take a look?
 * [andy@trulygood.com](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/andy@trulygood.com?output_format=md)

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘[Plugin: Multiple Sidebars] Bugs in method dynamic_sidebar()’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/multiple-sidebars_a4a4a4.svg)
 * [Multiple Sidebars](https://wordpress.org/plugins/multiple-sidebars/)
 * [Support Threads](https://wordpress.org/support/plugin/multiple-sidebars/)
 * [Active Topics](https://wordpress.org/support/plugin/multiple-sidebars/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multiple-sidebars/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multiple-sidebars/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [trulygood](https://wordpress.org/support/users/trulygood/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-multiple-sidebars-bugs-in-method-dynamic_sidebar/#post-2618472)
 * Status: resolved