douqu2481 2016-03-14 01:52
浏览 36

Woocommerce - 根据变化列出产品

I need for a project to sort via a php variable the entire product list by a specific variation of a custom attribute, I am having trouble listing products that have a specific variation, i have tried multiple statements with meta_query or tax_query similar to:

add_filter('woocommerce_ordering_args', 'custom_woocommerce_ordering_args');

function custom_woocommerce_ordering_args( $args ) {
    $args = array(
    'post_type' => 'product',
    'meta_query' => array(
        array(
            'key' => 'pa_attribute',
            'value' => 'attribute_value',
            'compare' => '=',
        )
    )
    );
    $query = new WP_Query( $args );
}

Where attribute is the variable attribute I have set, and the attribute_value is the value I am searching for.

It seems to do nothing to the product query.

Thank you in advance!

  • 写回答

0条回答 默认 最新

      编辑
      预览

      报告相同问题?

      手机看
      程序员都在用的中文IT技术交流社区

      程序员都在用的中文IT技术交流社区

      专业的中文 IT 技术社区,与千万技术人共成长

      专业的中文 IT 技术社区,与千万技术人共成长

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      客服 返回
      顶部