Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用WooCommerce中的函数向特定类别中的所有产品添加CSS类_Php_Css_Wordpress_Woocommerce_Hook Woocommerce - Fatal编程技术网

Php 使用WooCommerce中的函数向特定类别中的所有产品添加CSS类

Php 使用WooCommerce中的函数向特定类别中的所有产品添加CSS类,php,css,wordpress,woocommerce,hook-woocommerce,Php,Css,Wordpress,Woocommerce,Hook Woocommerce,我将如何使用函数向特定类别中的所有产品添加CSS类 函数DW\u remove\u add\u to\u cart\u按钮(){ 如果(is_product()&&!具有_术语('product has vendor'、'product_cat')){ 添加CSS类“我的自定义CSS类” } } 因此,在上面的代码中:如果查看的是产品页面,而不是类别“ProducthasVendor”,请添加CSS类 我该如何实现这一点呢?所以使用add_filter('wc_product_post_cl

我将如何使用函数向特定类别中的所有产品添加CSS类

函数DW\u remove\u add\u to\u cart\u按钮(){
如果(is_product()&&!具有_术语('product has vendor'、'product_cat')){
添加CSS类“我的自定义CSS类”
}
}

因此,在上面的代码中:如果查看的是产品页面,而不是类别“ProducthasVendor”,请添加CSS类


我该如何实现这一点呢?

所以使用add_filter('wc_product_post_class…)?只需尝试一下,没有任何改变。它没有添加类…wc_product_post_class只对单个产品有效,不在循环中。