Return to Snippet

Revision: 50790
at September 2, 2011 19:07 by distribuida


Initial Code
//REGISTER SIDEBAR
register_sidebar( array(
	'name' => 'Footer Area One',
	'id' => 'sidebar-3',
	'description' => 'An optional widget area for your site footer',
	'before_widget' => '<aside id="%1$s" class="widget %2$s">',
	'after_widget' => "</aside>",
	'before_title' => '<h3 class="widget-title">',
	'after_title' => '</h3>',
) );

register_sidebar( array(
	'name' => 'Footer Area Two',
	'id' => 'sidebar-4',
	'description' => 'An optional widget area for your site footer',
	'before_widget' => '<aside id="%1$s" class="widget %2$s">',
	'after_widget' => "</aside>",
	'before_title' => '<h3 class="widget-title">',
	'after_title' => '</h3>',
) );

register_sidebar( array(
	'name' => 'Footer Area Three',
	'id' => 'sidebar-5',
	'description' => 'An optional widget area for your site footer',
	'before_widget' => '<aside id="%1$s" class="widget %2$s">',
	'after_widget' => "</aside>",
	'before_title' => '<h3 class="widget-title">',
	'after_title' => '</h3>',
) );


//COUND THE NUMBER OF FOOTER SIDEBARS TO ENABLE DYNAMIC CLASSES FOR THE FOOTER
function custom_footer_sidebar_class() {
    
	$count = 0;
    if ( is_active_sidebar( 'sidebar-3' ) ) $count++;
    if ( is_active_sidebar( 'sidebar-4' ) ) $count++;
	if ( is_active_sidebar( 'sidebar-5' ) ) $count++;
	
	$class = '';
	switch ( $count ) {
		case '1': $class = 'one'; break;
		case '2': $class = 'two'; break;
		case '3': $class = 'three'; break;
	}
	
	if ( $class ) echo 'class="' . $class . '"';
}

Initial URL

                                

Initial Description

                                

Initial Title
Wordpress: Register Sidebar

Initial Tags
wordpress

Initial Language
PHP