通过functions.php调用wordpress侧边栏

时间:2016-05-02 15:23:22

标签: php wordpress function woocommerce

我只是好奇 - 有没有办法在功能内调用侧边栏?假设我们有一个名为sidebar-A的侧边栏。我以这种方式注册:

function custom_sidebars() {

     register_sidebar( array(
        'id'            => 'sidebar-a',
        'class'         => 'sidebar-a',
        'name'          => __( 'sidebar-a', 'text_domain' ),
        'description'   => __( 'sidebar-a', 'text_domain' ),
        'before_title'  => '',
        'after_title'   => '',
        'before_widget' => '',
        'after_widget'  => '',
    ) );

}
add_action( 'widgets_init', 'custom_sidebars' );

我有一个动作(负责在我的主题中显示特定的代码片段:

function bookshop_utils() { 
echo "some text";
echo "some text2";
dynamic_sidebar('sidebar-a');
}

add_action( 'woocommerce_bookshop_utilities', 'bookshop_utils' );

但正如您所想 - 在函数内键入此类代码(dynamic_sidebar)无法正常工作。任何想法如何使它工作?

0 个答案:

没有答案