The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Woocommerce - Paginated "On Sale" page (2 posts)

  1. tomiford
    Posted 2 years ago #


    I need to create a paginated Product Archive page that lists all the woocommerce products that are "on sale" in a shop.

    I do not want to add a "Sale" category and manually assign products to that, it needs to get the products automatically.

    I found this post that almost answers my question but as I am new to wordpress I am not sure how I access the template "product-archive_sale.php" in a page template.

    Like the post in the above link I have copied woocommerce/product-archive.php to my theme and named it "woocommerce/product-archive_sale.php" and added the code below above if ( have_posts() ) : line...

    $args = array(
        'post_type'      => 'product',
        'meta_query'     => array(
            'relation' => 'OR',
            array( // Simple products type
                'key'           => '_sale_price',
                'value'         => 0,
                'compare'       => '>',
                'type'          => 'numeric'
            array( // Variable products type
                'key'           => '_min_variation_sale_price',
                'value'         => 0,
                'compare'       => '>',
                'type'          => 'numeric'
    query_posts( $args );

    This gets the sale products but now I don't know how to use it. I need to a URL like domain.com/sale/ that has the Woocommerce Sidebar on the page.

    Any advice is much appreciated.

  2. wlanni
    Posted 1 year ago #

    At the top of the product-archive_sale.php page, right after the opening <?php code, you need to add the template name stuff, e.g.:

    * Template Name: Sale Products
    * Description: The Template for displaying product archives, including the main shop page which is a post type archive.


    Save and upload. The in your sale page, select the Sale Products template in the right column drop down for templates.

Topic Closed

This topic has been closed to new replies.

About this Topic