最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

loop - Conditional query that displays on Woo product attribute pages

programmeradmin3浏览0评论

I have a custom query set up that currently modifies the product category pages of my website. I would also want this code to affect the product attribute archive pages of my website, but I am having trouble with the conditional statements.

Here is the conditional statement I am using now that modifies my product category pages:

function display_custom( $query ) {
if(!is_admin() && (in_array ( $query->get('post_type'), array('product') ) || $query->get('product_cat') != '') )
    {

CUSTOM QUERY GOES HERE

}
    return $query;
}
add_action('woocommerce_product_query', 'display_custom',800);

I tried just using if (!is_admin()) but it didn't work.

Any pointers to make this query work on the product attribute pages?

发布评论

评论列表(0)

  1. 暂无评论