- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经使用 wp_list_categories 来创建类别列表并将$ args设置为如下所示,以将类别“current-cat”添加到当前类别项目中,但一切正常,但是当我单击“所有类别”时,由于菜单菜单无法突出显示,因为“当前类别”类别不适用于“所有类别”项目。
如何将current-cat类应用于“所有类别”?
我的设定
<ul>
<?php
$args = array(
'show_option_all' => 'All Categories',
'orderby' => 'id',
'style' => 'list',
'use_desc_for_title' => 0,
'hierarchical' => 0,
'title_li' => '',
'current_category' => 0
);
wp_list_categories( $args );
?>
</ul>
最佳答案
如果不回显结果,而是将其存储在变量中,我们可以检查该类是否存在。如果不是这样,则意味着我们属于“全部”类别。
为此,我做了以下工作:
$args = array(
'show_option_all' => 'All',
'title_li' => '',
'echo' => false, // dont echo the results
'taxonomy' => 'tribe_events_cat'
);
$categories = wp_list_categories($args); // store the results in a variable
if(strpos($categories,'current-cat') == false) { // check if the class exists
// add the class to the All item if it doesn't exist
$categories = str_replace('cat-item-all', 'cat-item-all current-cat', $categories);
}
echo $categories;
关于php - WordPress wp_list_categories,如何突出显示 “All categories”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27914959/
我目前正在使用以下脚本在无序列表中输出我所有的 wordpress 类别。如何获得带有额外标记的输出? 例如: Category 1 › Category 2 › 代
我需要为 wp_list_categories 编写一个自定义函数,这样它们就不是显示分层链接列表,而是一个复选框列表,父项显示为 h3 标签。 最终输出看起来像http://jsfiddle.net
我正在使用 WordPress。 有多个类别及其子类别。在一般页面中,我显示所有一级类别。这是我的代码: $args = array( 'type' => 'product-items',
下面的脚本创建网站中的类别列表(不包括“未分类”中的类别)。 如果可能,我想对其进行修改,使其仅列出顶级类别(没有子类别)... 我认为“深度”=1 参数可以解决问题,但事实并非如此。它列出了所有类别
我只想显示当前帖子页面的类别名称和链接。例如,我有一个帖子可以说“test123”,我已经将帖子与 2 个类别“ab”、“bc”链接起来。但是我有 5 个不同的类别。因此,当用户转到“test123”
上下文:使用带有 jigoshop 插件的 Wordpress 我正在使用 wp_list_categories 带来运作良好的产品类别并带来所需的列表。唯一的问题是类别的排序。我使用了几个 orde
我正在尝试删除/替换 WordPress 使用的类别元素上的 title 属性。我使用的是 WordPress 2.9.1,代码如下: Manufacturers
1.用分类做为导航拦 <?php wp_list_categories('depth=2&title_li=0&orderby=name&show_coun
我已经使用 wp_list_categories 来创建类别列表并将$ args设置为如下所示,以将类别“current-cat”添加到当前类别项目中,但一切正常,但是当我单击“所有类别”时,由于菜单
我在使用 Style 显示我的 wp_list_categories 时遇到问题。我已经在使用 args 等,但这似乎对解决问题没有帮助。 我想为单篇文章显示相同的子类别。 这里是我的代码: term
我有一个 jsfiddle.net/vanduzled/AgAwK/结果是 wp_list_categories 的输出: 所以我在 wordpress 中有一个带有子类别的类别列表,我希望它显示在我
好的,我有类别和子类别。 类别: 本田 -思域 -雅阁 丰田 -佳美利 -花冠 日产 -千里马 -反之亦然 现在我只想使用 wp-list-categories 随机显示其中的 5 个 Sub_Cat
我正在尝试从 wp_list_categories 的最后一个链接中删除最后一个分隔符(通常是 标记,但我将其更改为“//”)。 基本上我想要这个: 类别 1//类别 2//类别 3// 看起来像这
我是一名优秀的程序员,十分优秀!