简体   繁体   English

WordPress样式类别小部件

[英]Wordpress style category widget

I'm trying to find out how to style only the category widget. 我试图找出如何仅设置类别小部件的样式。 All widgets are using the same div names. 所有小部件都使用相同的div名称。 Is there a code I can use to differentiate the category widget? 有没有可以用来区分类别窗口小部件的代码?

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: 请查看register_sidebar的文档,以了解如何指定before_widget属性:

http://codex.wordpress.org/Function_Reference/register_sidebar 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. 如果您要编辑内置窗口小部件,建议您将其代码复制到您的functions.php中,而不要在原地进行编辑,以使升级WordPress不会删除您的修改。 Just register the widget with a different name. 只需使用其他名称注册小部件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM