Archived topic
Show category on woo-coomerce tiles
15 replies · Started by limolab on September 17, 2020
Hello, in this page: https://shop.geogym.it/
Is it possible to show the category on the tile of the product?
Hope to be clear.
Thanks
Hi there,
where would you want the Category name displayed ? Above the single product title ?
Hello, yes on the tile, under the title.
Thanks.
Ok so try this:
1. Create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
2. Add this code to the Hook element text area:
<?php
$terms = get_the_terms( $post->ID, 'product_cat' );
if ( $terms && ! is_wp_error( $terms ) ) :
if ( isset( $terms ) ) {
echo '<span class="woo-cat-term">' . $terms[0]->name . '</span>';
}?>
<?php endif;?>
3. Select the woocommerce_single_product_summary hook from the hook list
4. Check Execute PHP
5. Set the Priority to 9
6. On Display Rules set Location to Products > All Products
Hi, thanks for your quick response.
woocommerce_single_product_summary_hook i can't find this on the hook list, i find only this: woocommerce_single_product_summary, i don't know if it's the same.
I've follow the procedure but still doesn't work.
Hope to be clear.
Thanks
Oops - that was my typo - yes thats the correct hook. I corrected the code above.
I just checked your site and I can see the Category below the title on the Single Product page.
Do you want this to appear in the Product Archives ?
Hello. No problem :)
yeah i'd like to see the category on the tiles in the home page.
In this section:-> I PRODOTTI GEOGYM
Is it possible to do that?
Thanks.
Change the Display Rules to Product Archive which is the Shop Page.
Hi, thanks for yor response.
Can you be please more specific?
Where can i find "Product Archive" ?
Thanks
SHould be in the display rules towards the bottom:
https://www.screencast.com/t/5bCGgFFEUoBx
Hello.
Thanks for your response.
unfortunately still doesn't work.
I can give you the access to my site if you want.
Thanks.
Sorry what doesn't work? The display rules?
Yes, i'd like to show the category name under the title of the product in this page -> https://shop.geogym.it/
But as you can see it show only the title of the product and not the category.
Hope to be clear.
Thanks
Follow the steps here:
https://generatepress.com/forums/topic/show-category-on-woo-coomerce-tiles/#post-1447061
And set the following Display Rules to:
1. Location > Product Archive
2. Location > Product Category Archives > All Archives.
Hello,
I've follow the steps.
Still doesn't work.
https://imgur.com/a/Irph2mi
see the screenshot.
If you want i can give you the access.
Thanks