Return to Snippet

Revision: 14432
at June 3, 2009 22:17 by kstetson


Initial Code
// use in functions.php:

<?php
// Multiple Sidebars
if ( function_exists('register_sidebar') ) {
	register_sidebar(array(
		'name'=>'Page',
		'before_widget' => '<li>',
		'after_widget' => '</li>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	));
	register_sidebar(array(
		'name'=>'Blog',
		'before_widget' => '<li>',
		'after_widget' => '</li>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	));
	register_sidebar(array(
		'name'=>'Single',
		'before_widget' => '<li>',
		'after_widget' => '</li>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	));
}


// use in sidebar.php:

<?php // Load Dynamic Sidebars
if(!function_exists('dynamic_sidebar')) { 
	showDefault();
} else { 
	if(is_front_page()) {
		if(!dynamic_sidebar('homepage')) {
			showDefault();
		}
	} else {
	 	if(!dynamic_sidebar('global')) {
	  		showDefault();  
		}
	}
}
?>

Initial URL

                                

Initial Description
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.

Initial Title
Multiple Dynamic Sidebars in Wordpress

Initial Tags
wordpress

Initial Language
PHP