添加" before_body"用于Wordpress Sidebars?

时间:2014-09-05 05:28:31

标签: php wordpress

Wordpress可以这样做:

function _tk_widgets_init() {
    register_sidebar( array(
        'name'          => __( 'Sidebar', '_tk' ),
        'id'            => 'sidebar-1',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );
}
add_action( 'widgets_init', '_tk_widgets_init' );

这会产生这样的结果:

<aside>
    <h3></h3>
    BODY 
</aside>

我需要做的是最终:

<aside>
    <h3></h3>
    <div class="anotherBlock">BODY</div>
</aside>

这可能吗?

1 个答案:

答案 0 :(得分:0)

解决它已经存在的问题:

register_sidebar( array(
    'name'          => __( 'Sidebar', '_tk' ),
    'id'            => 'sidebar-1',
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'before_title'  => '<h3 class="widget-title">',
    'after_title'   => '</h3><div class="mainWidgetBody">',
    'after_widget'  => '</div></aside>',


) );