wp_list_categories() 将 span 添加到类别名称

发布于 2024-12-03 03:23:19 字数 360 浏览 3 评论 0原文

我已经尝试了一堆“解决方案”,但不允许我添加一个简单的

<span></span>

使用functions.php /default-widgets.php 到类别名称,例如。

<li><a><span></span>Category 1</a></li>

我最接近的是使用 str_replace 替换类别帖子计数。 我不想直接从主题调用小部件,因为它会弄乱顺序或使用 jquery,这是他们“轻松”执行此操作的一种方法,还是 WP 不允许这样做。

谢谢

I've tried a heap of "solutions" but non allow me add a simple

<span></span>

using functions.php /default-widgets.php
to the category name, eg.

<li><a><span></span>Category 1</a></li>

the closest I've come replaces the category post count using str_replace.
I don't want to call the widget straight from the theme because it messes up the order or use jquery, is their a way of doing this "easily" or will WP not allow it.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界如花海般美丽 2024-12-10 03:23:19

最简单的方法绝对是编辑核心文件。

如果您使用 WordPress 3.2.1,请转到文件夹 wp-includes 并查找 category-template.php

并转到第 874 行...

$link .= ' (' . intval($category->count) . ')';

并添加您需要的标记,例如 < strong>span 并删除括号。

$link .= '<span>' . intval($category->count) . '</span>';

Definately the easiest way is to edit the corefiles.

If your using wordpress 3.2.1, go to the folder wp-includes and look for category-template.php

And go to line 874...

$link .= ' (' . intval($category->count) . ')';

and add in what markup you need too, for example span and removing the brackets.

$link .= '<span>' . intval($category->count) . '</span>';

and Voila

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文