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.
- The topic ‘Woocommerce – Paginated "On Sale" page’ is closed to new replies.