web-dev-qa-db-ja.com

register_sidebarは 'id'と 'class'を無視します

私は以下の方法でウィジェットエリアを登録しています。

if ( function_exists('register_sidebar') )
    register_sidebar( array(
    'name' => __( 'Footer Widgets', 'hex'),
    'id' => 'footer-widgets',
    'class' => 'footer-widgets',
    'description' => __( 'Widgets will appear in the blog, between the end of content and footer', 'hex' ),
    'before_widget' => '<li class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
) );

そしてidclassの両方は無視されます、私が手に入れるのはウィジェットそのものだけです - ウィジェット領域の一番上の要素は<li>

ウィジェットが表示されているindex.phpにdivを付けて単純にラップできることはわかっていますが、これは想定していませんか。

4
ilyo

Register_sidebarのidパラメータは、HTML出力に直接関連していません。これは、$ widget_objectが構築されたときに各サイドバーを識別するために使用されます。

クラスはbefore_widgetマークアップに追加されるべきです。

http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/widgets.php#L1128 はどこにありますかクラスが解析されます。

7
Chris_O