0

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. sort bar and result showing

0

You 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.