如何在侧边栏小部件中修改和设置WooCommerce产品类别计数NUMBER的样式 [英] How to modify and style WooCommerce product category count NUMBER in sidebar widget
问题描述
好吧,所以我找到了一种方法来修改首页中类别计数的"woocommerce_subcategory_count_html",就像在functions.php中一样,并在css中对其进行样式设置.这是一张图片,显示我的意思:
Ok, so I have found the way to modify the 'woocommerce_subcategory_count_html' for the categories count in the home page like so in the functions.php and style it in css. Here is an image to show what I mean:
add_filter('woocommerce_subcategory_count_html', 'filter_woocommerce_subcategory_count_html', 10, 2);
function filter_woocommerce_subcategory_count_html($mark_class_count, $category)
{
$mark_class_count = ' <mark class="count">' . $category->count . '</mark>';
return $mark_class_count;
}
但是,我无法在产品页面侧边栏中找到对产品类别计数编号执行相同操作的方法:
But, I cant find a way to do the same thing for the product category count number in the product page sidebar:
我们在每个类别的右边都有类别和计数.我要去掉括号并设置计数数字的样式.
We have the categories and the count number to the right for each. I want to remove the brackets and style the count number.
我已经尝试了一些示例,但是找不到侧边栏类别列表特有的内容.
I have tried crawling the net for examples, but I cant find anything specific to the sidebar category list.
这可能吗?
如果有人有什么想法可以找到解决此特定问题的解决方案,将不胜感激.
If anyone has any ideas where I can find a solution to target this particular issue, it will be much appreciated.
谢谢.
推荐答案
您可以在主题文件夹中的function.php文件中使用此钩子
You can use this hook in your function.php file in theme folder
add_filter( 'wp_list_categories', 'update_count_output' );
function update_count_output($output) {
return preg_replace('/\<span class\=\"count\"\>\((\d+)\)\<\/span\>/', '<span class="count">$1</span>', $output);
}
然后您可以使用CSS设置计数样式
Then you can style the count number using CSS
这篇关于如何在侧边栏小部件中修改和设置WooCommerce产品类别计数NUMBER的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!