Support » Plugins » Woocommerce – Paginated "On Sale" page

  • Hi

    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 that has the Woocommerce Sidebar on the page.

    Any advice is much appreciated.

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘Woocommerce – Paginated "On Sale" page’ is closed to new replies.