Created
July 22, 2018 09:52
-
-
Save mdjwel/7b40924e881c17c2ec6c4c3b6425577b to your computer and use it in GitHub Desktop.
Get WooCommerce featured products Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tax_query[] = array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'name', | |
'terms' => 'featured', | |
'operator' => 'IN', // or 'NOT IN' to exclude feature products | |
); | |
// The query | |
$query = new WP_Query( array( | |
'post_type' => 'product', | |
'post_status' => 'publish', | |
'ignore_sticky_posts' => 1, | |
'posts_per_page' => !empty($settings['show_count']) ? $settings['show_count'] : -1, | |
'order' => !empty($settings['order']) ? $settings['order'] : 'DESC', | |
'tax_query' => $tax_query // <=== | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment