最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - WooCommerce category display in custom page

programmeradmin4浏览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.

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 badges
Add a comment  | 

1 Answer 1

Reset to default 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.

发布评论

评论列表(0)

  1. 暂无评论