我想为默认小部件分配一个新的CSS类<ul>
在WordPress中的页面/帖子创建页面。我该怎么做?
请参见下图。
我想为默认小部件分配一个新的CSS类<ul>
在WordPress中的页面/帖子创建页面。我该怎么做?
请参见下图。
不编辑父主题的functions.php
文件
register_sidebar( array(
\'name\' => __( \'Sidebar name\', \'theme_text_domain\' ),
\'id\' => \'unique-sidebar-id\',
\'description\' => \'\',
\'class\' => \'add class here\',
\'before_widget\' => \'<li id="%1$s" class="widget %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h2 class="widgettitle">\',
\'after_title\' => \'</h2>\'
) );
将其复制到您孩子的主题functions.php
然后在那里进行更改,或者注册一个新的小部件。然后你可以从你孩子的主题functions.php
像这样:
add_action( \'your_hook\', \'new_widget\' );
function new_widget() {
if ( is_your_conditional_tag() && is_active_sidebar( \'new-widget\' ) ) {
dynamic_sidebar( \'new-widget\', array(
\'before\' => \'<div class="new-widget">\',
\'after\' => \'</div>\'
) );
}
}
还可以将更多类添加到dynamic_sidebar 作用转到您的function.php
并找到您的小部件代码
您必须添加或编辑class
边栏代码中的参数\'class\' => \'new-class\',
它是这样的:
register_sidebar(array(
\'name\' => __( \'Right Hand Sidebar\' ),
\'id\' => \'right-sidebar\',
\'class\' => \'new-class\',
\'description\' => __( \'Widgets in this area will be shown on the right-hand side.\' ),
\'before_title\' => \'<h1>\',
\'after_title\' => \'</h1>\'
));
你必须退房Wordpress Codex 更多用法你写错了问题。它不在小部件上,而是在帖子/页面描述上。
根据codex,您需要向css文件添加额外样式。您可以通过代码添加类,但这是更好的解决方案。看到这个了吗codex 详细信息链接
#content ul {margin: 0.3em 1em; list-style-position: outside; list-style:url(ball.gif) disc; font-size:98%}
#content ul ul {margin-top: 0.3em; list-style:url(bullet.gif) square; font-size:96%}
#content ul ul ul {margin-top: 0.3em; list-style:url(ball1.gif) circle; font-size:98%}
#content li, #content li li, #content li li li {padding:0.25px 10px 5px 0.25em}
我正在用许多小部件构建一个网站。它们是高度定制的。当站点处于活动状态时,几个管理员/编辑器必须编辑这些小部件。现在,我很害怕看到一个小部件(及其配置)可以在一次鼠标移动中完全擦除(将其从侧栏中删除)。有没有什么方法可以防止小部件被删除,同时保持编辑其内容的能力?此外,在我看来,管理中的widget管理页面为“添加widget”模块提供了太多的空间,而为“激活的widget”模块提供的空间不足。这在创建站点时很有用,但在完成站点时却毫无用处。有没有办法切换这些模块的大小?非常感谢