0

The Issue:

$footer_widgets = array(
    'name'          => sprintf(__('Sidebar %d'), $i ),
    'id'            => "sidebar-$i",
    'description'   => '',
    'class'         => '',
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget'  => '</li>',
    'before_title'  => '<h2 class="widgettitle">',
    'after_title'   => '</h2>'
);

register_sidebars(4, $footer_widgets);

Is producing the image below and I'm not sure why. When I copy and paste the code from the register_sidebars codex it still does not work properly.

Widgets

What Works:

When I remove $footer_widgets["name"] it all of a sudden works again. I can't seem to change the name to suit my needs so I can actually continue building my theme.

My apologies if this is a repeat. I did take the time to scour stackoverflow and other search engines and did not find anything that could help me. Any help is appreciated!

4

1 回答 1

2

参数部分有一个特殊的注释说:

注意:如果从上面的默认用法复制,请删除sprintf( )包装函数。

工作代码:

add_action( 'widgets_init', 'so16969325_widgets_init' );
function so16969325_widgets_init()
{
    $footer_widgets = array(
        'name'          => __( 'Sidebar %d', 'txt_domain' ),
        'id'            => "sidebar-$i",
        'description'   => '',
        'class'         => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget'  => '</li>',
        'before_title'  => '<h2 class="widgettitle">',
        'after_title'   => '</h2>'
    );
    register_sidebars( 4, $footer_widgets );
}
于 2013-06-07T00:56:02.707 回答