admin管理员组

文章数量:1426810

I have a query that's stopped working since Woo 3.6 upgrade I think. I'm trying to get products in a category that are featured. Any help would be much appreciated:)

<?php

                            $args = array(
                                        'post_type'         => 'product',
                                        'post_status'       => 'publish',
                                        'posts_per_page'    => 4,
                                        'orderby'           => 'date',
                                        'order'             => 'DESC',
                                        'post__in'          => wc_get_featured_product_ids(),
                                        'tax_query'         => array(
                                            array(
                                                'taxonomy'  => 'product_cat',
                                                'field'     => 'ID',
                                                'terms'     => intval( $cat_id )
                                            )
                                        )
                                    );

                            $query = new WP_Query( $args ); 
                        ?>

Unfortunately this code no longer works and returns nothing. But if I comment out the 'post__in' line it works but returns the latest products in that category and not the featured. Hope that makes sense.

本文标签: loopWoocommerce featured products query no longer working