why the is_active_sidebar() function return always false?
Function.php code:
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Footer Column 2',
'id' => 'footer-column-2', // I also added the ID but doesn't work
'before_widget' => '<div id="%1$s" class="omc-footer-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>'
));
}
footer.php code:
<?php if ( is_active_sidebar( 'footer-column-2' ) ) : ?>
<div class="omc-footer-widget-column">
<?php dynamic_sidebar( 'Footer Column 2' ); ?>
</div><!--- /second-footer-column -->
<?php endif; ?>
I tried with the name or id but not working. Any idea?
Thanks
EDITED: I have more dynamic sidebars and I use this code to register these:
//register custom sidebars add_action( 'widgets_init', 'register_theme_sidebars_dynamic' ); // and this function...I think the problem is here: function register_theme_sidebars_dynamic(){ global $wpdb; //post and pages sidebars $widgetized_pages = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'omc_page_sidebar'", '')); if($widgetized_pages){ foreach($widgetized_pages as $w_page){ $widget_id = strtolower(str_replace(' ', '_', $w_page)); register_sidebar(array( 'name' => $w_page, 'id' => 'jw_widgetsection_'.$widget_id, 'description' => '', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '' )); }// For each }//End If }
Footer Column 2
sidebar?is_active_sidebar()
returnstrue
if the indicated sidebar has Widgets, and returnsfalse
otherwise.