Tutorials, WooCommerce, Wordpress

Edit Woo Commerce ShortCode Query

08 December 2017

Sometimes we need to change the default query of Woo Commerce shortcodes. Here we will see how to Edit Woo Commerce ShortCode Query with custom coding.

function codecanal_recent_products_shortcode_args( $args, $atts ){

    $args['meta_query'] = array(
		'key'     => 'color',
		'value'   => 'blue',
		'compare' => 'NOT LIKE',

    return $args;

add_filter( 'woocommerce_shortcode_products_query', 'codecanal_recent_products_shortcode_args', 10, 2 );

When you filter the woocommerce_shortcode_product_query args you can set the any WordPress meta query to WP_Query. You can see more arguments to Codex.

Leave a Comments