WordPress 风格类别小部件
我正在尝试找出如何仅设置类别小部件的样式。所有小部件都使用相同的 div 名称。我可以使用代码来区分类别小部件吗?
I'm trying to find out how to style only the category widget. All widgets are using the same div names. Is there a code I can use to differentiate the category widget?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的主题应该将小部件包含在某个标签中,并具有该小部件特有的类。请参阅 register_sidebar 的文档,了解如何指定 before_widget 属性来执行此操作:
http://codex.wordpress。 org/Function_Reference/register_sidebar
如果失败,如果小部件没有任何可以定位的唯一选择器,那么您必须创建它们。如果您要编辑内置小部件,我建议将其代码复制到您的functions.php中,而不是就地编辑它,这样升级WordPress就不会删除您的修改。只需使用不同的名称注册小部件即可。
Your theme should enclose widgets in some tag with a class unique to that widget. Look at the documentation for register_sidebar for how to specify the before_widget property to do so:
http://codex.wordpress.org/Function_Reference/register_sidebar
Failing that, if the widget doesn't have any unique selectors you can target, then you'll have to create them. If you're going to edit a built-in widget, I recommend copying its code into your functions.php rather than editing it in place, so that upgrading WordPress doesn't remove your modifications. Just register the widget with a different name.