Dear StackOverflow friends,
I use this Woocommerce shortcode

[sale_products per_page=”12″]

to show only products on sale on a page.

Now I need to show only scheduled sale products, in other words, only the products whose sale price is scheduled in WordPress > products > general > sale price > schedule

Thank for your help!


My suggestion is:

Copy the sale_products shortcode into you theme(functions.php) or a custom plugin(a php-file inside the plugins folder). Copy the full function named sale_products from /wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php. It starts around line 560.

Step 1: Copy everything between

public static function sale_products( $atts ) {
    global $woocommerce_loop;


    return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';

Into your theme or plugin.

Step 2: Change the function declaration from

public static function sale_products( $atts ) {


function scheduled_sale_products( $atts ) {

Step 3: Hook the shortcode into wordpress.

add_shortcode( 'scheduled_sale_products', 'scheduled_sale_products' );

Step 4: Alter the WP_Query.

Add these lines of code

$meta_query[] = array(
    'key' => '_sale_price_dates_to',
    'value' => time(),
    'compare' => '<='

After this line(around line 580)

$meta_query[] = WC()->query->stock_status_meta_query();

Now you should be able to use the shortcode like this:

[scheduled_sale_products per_page="12"]

Related Wordpress search:

, , , ,

Wordpress related questions and answers: