Last active
March 8, 2018 22:55
-
-
Save WillBrubaker/0ffdc0aed0c574b6c3a5 to your computer and use it in GitHub Desktop.
Filters the default WooCommerce product category shortcode to only include items on sale
This file contains hidden or 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
add_filter( 'woocommerce_shortcode_products_query', 'wooninja_only_sale_items', 10, 2 ); | |
function wooninja_only_sale_items( $args, $atts ) { | |
if ( $atts['category'] ) { | |
$product_ids_on_sale = wc_get_product_ids_on_sale(); | |
$args['post__in'] = array_merge( array( 0 ), $product_ids_on_sale ); | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment