注册表边栏忽略‘id’和‘class’

时间:2012-07-21 作者:ilyo

我使用以下内容注册小部件区域:

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,但这不是应该做到的吗?

1 个回复
SO网友:Chris_O

register\\u侧栏中的id参数与html输出没有直接关系。它用于在构建$widget\\u对象时标识每个侧栏。

应将该类添加到before\\u小部件标记中。

http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/widgets.php#L1128 是解析类的位置。

结束

相关推荐

StylesSwitcher或ThemesSwitcher,允许用户从移动设备切换回标准视图

我用CSS创建了一个移动版的网站,所有样式都在一个样式表中(使用@media only screen and (max-width: 480px), only screen and (max-device-width: 480px) 定义移动样式)。当它都在一个样式表中时,它工作得很好。但我想允许用户切换回标准视图,即使他们从移动设备查看站点。我不知道如何允许用户覆盖@media, 所以我似乎有两个选择:(1)单独的样式表加上样式切换脚本,或者(2)单独的主题加上主题切换。理论上,样式切换器应该可以做到这