Display Category Name
Q: I want to display the direct parent category name of the current product and just the direct parent. When I search, all I can find is code that lists all the categories of that product (eg: grandparent).
A: Template code provided by the user on the Forum to display the product category:
$terms = get_the_terms( $post->ID, 'product_cat' );
$term = current($terms);
echo "<h1 class="shop-category-title">".$term->name."</h1>";
To make a list of the categories:
$terms = get_the_terms( $post->ID, 'product_cat' );
echo '<ul>';
foreach ($terms as $term) {
echo '<li><a href="'.get_term_link($term->slug, 'product_cat').'">'.$term->name.'</a></li>';
}
echo '</ul>';
-
Getting Started
-
Jigoshop Settings
-
Creating Products
-
Using Jigoshop
-
Customize Jigoshop
-
Testings – in case of problems on Jigoshop web site
-
FAQ – Jigoshop plugin user questions
- Add a new tab to a product page / Custom tabs on product pages?
- Adding a Continue Shopping button to the single product page
- Adding Product Category Terms in a dropdown box for Custom Post Meta
- Add Alternate text on product picture and title
- Adding buttons / info to the end of each product
- View all (171 more)
-
FAQ – Jigoshop extensions user questions
-
API
-
Screencasts