Filter to show only “featured” products, compatible with WC 3+.
Ticket URL: https://wp-types.com/forums/topic/toolset-views-not-showing-_featured-in-view-gui-for-woocommerce/
As of WC 3, Featured Products are managed a bit differently. Before, we could use the hidden field “_featured” to filter a View. Now the flag has been migrated to a hidden taxonomy “product_visibility” and has a term name “featured”. Until this is supported in the Views GUI, a filter can be used to add the “featured” product filter to a search:
/* --------------------------------------------- */ // WooCommerce 3+ featured products filter // Only include "featured" products add_filter( 'wpv_filter_query', 'featured_products',99,3 ); function featured_products( $query_args,$views_settings, $view_id) { if ($view_id == 10){ $query_args = array( 'post_type' => 'product', 'tax_query' => array( array( 'taxonomy' => 'product_visibility', 'field' => 'name', 'terms' => 'featured', 'operator' => 'IN' ), ), ); } return $query_args; }
Be sure to change $view_id == 10 to match your View.