Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - Show product categories on product page
- add_action( 'woocommerce_single_product_summary', 'show_product_categories', 25 );
- function show_product_categories() {
- global $product;
- $terms = get_the_terms( $product->get_id(), 'product_cat' );
- if( $terms ) {
- $names = array();
- foreach ( $terms as $term ) {
- $names[] = $term->name;
- }
- print '<p>Categories: '.join( ', ', $names ).'</p>'.PHP_EOL;;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement