/ Published in: PHP
To arrange multiple dynamic sidebars in wordpress, add the following code snippet into functions.php. The sidebar should then appear in the dropdown menu in wordpress under the widgets section. Next, go into your sidebar.php file & edit the dynamic sidebar tag by setting conditionals for when certain sidebars can be used in the sidebar.php file.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// use in functions.php: <?php // Multiple Sidebars 'name'=>'Page', 'before_widget' => '<li>', 'after_widget' => '</li>', 'before_title' => '<h2>', 'after_title' => '</h2>', )); 'name'=>'Blog', 'before_widget' => '<li>', 'after_widget' => '</li>', 'before_title' => '<h2>', 'after_title' => '</h2>', )); 'name'=>'Single', 'before_widget' => '<li>', 'after_widget' => '</li>', 'before_title' => '<h2>', 'after_title' => '</h2>', )); } // use in sidebar.php: <?php // Load Dynamic Sidebars showDefault(); } else { if(is_front_page()) { if(!dynamic_sidebar('homepage')) { showDefault(); } } else { if(!dynamic_sidebar('global')) { showDefault(); } } } ?>