I'm trying to display WooCommerce category on custom page which I can do it with WooCommerce short-code but I was unable get button like (showing all result),(default sorting).
How can I get these thing in custom page as we get it by default in shop page, to make more clear I have attached screenshot of my requirement.
I'm trying to display WooCommerce category on custom page which I can do it with WooCommerce short-code but I was unable get button like (showing all result),(default sorting).
How can I get these thing in custom page as we get it by default in shop page, to make more clear I have attached screenshot of my requirement.
Share Improve this question edited Dec 9, 2017 at 16:37 Drupalizeme 1,6262 gold badges13 silver badges17 bronze badges asked Dec 8, 2017 at 22:04 synersyner 12 bronze badges1 Answer
Reset to default 0You have to create a custom template for that. The template have to clone the content of taxonomy-product_cat.php
, which thankfully is basically a single line.
Your template will be something like this:
<?php
/**
* Template Name: YOUR TEMPLATE NAME HERE
*/
// Set the parameters of your query
$args = array( 'post_type' => 'product', 'product_cat' => 'YOUR_CATEGORY_SLUG_HERE' );
// Override directly the query of the page, so that it is propagated to all the functions and doesn't break any WooCommerce feature
query_posts( $args );
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
wc_get_template( 'archive-product.php' );
However I invite you to think about what you want to achieve exactly and if this is the way to achieve it. If you create a category page like this, the result will be a duplicated content without a canonical link, which is very bad for Google.