为什么is\\u active\\u sidebar()函数返回的总是false?
作用php代码:
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>\'
));
}
页脚。php代码:
<?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; ?>
我试过用这个名字或id,但没用。有什么想法吗?
谢谢
编辑:我有更多动态边栏,我使用此代码注册这些边栏:
//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
}