0
votes

When building a WooCommerce site they have made it really easy to display categories and sub categories on the archive and category pages.

However does anyone know if it's possible to add a the list of categories/sub categories to the (content-single-product) page template?

I have a store that had only a handfull of products and we would like users to be able to quick select from the side menu rather than go back and forward between the archive page and the product pages.

Thanks to anyone who can help.

2
The best thing is to use the widget bar for that or not? Where do you want to display them and how (more details please)? On content-single-product page it will display only the categories and sub categories related to the displayed product (one product ID)…LoicTheAztec
"When building a WooCommerce site they have made it really easy to display categories and sub categories on the archive and category pages. " Could someone be so kind and point me out- where and how can I add sidebar with product categories on categories pages ? I have Categories sidebar on main shop page, but when I go to subcategory - the sidebar with category list is gone. Any link..anything please would be helpful. Not a single explanation on that on entire stackoverflow..Blue

2 Answers

0
votes
$prod_cat_args = array(
  'taxonomy'     => 'product_cat', //woocommerce
  'orderby'      => 'name',
  'empty'        => 0
);

$woo_categories = get_categories( $prod_cat_args );

foreach ( $woo_categories as $woo_cat ) {
    $woo_cat_id = $woo_cat->term_id; //category ID
    $woo_cat_name = $woo_cat->name; //category name

    $return .= '<a href="' . get_category_link( $woo_cat_id ) . '">' . $woo_cat_name . '</a>';
}
0
votes
$prod_cat_args = array(
'posts_per_page'   => 5,
    'offset'           => 0,
    'category'         => '',
    'category_name'    => '',
    'orderby'          => 'date',
    'order'            => 'DESC',
    'include'          => '',
    'exclude'          => '',
    'meta_key'         => '',
    'meta_value'       => '',
    'post_type'        => 'post',
    'post_mime_type'   => '',
    'post_parent'      => '',
    'author'       => '',
    'post_status'      => 'publish',
    'suppress_filters' => true 
);
 you can also edit all fields try this