Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #787220

    Hi,

    It´s possible to explain how can I display categories and tags on product index pages? Right Near the Title, Price and add to card button.

    Thanks,

    #787597

    Hey PT0060,

    Thank you for using Enfold.

    This is possible but you won’t be able to click on each category because the whole product item is already wrapped inside an anchor link. Add this code in the functions.php file

    function ava_woocommerce_after_shop_loop_item_title( $woocommerce_template_loop_product_title, $int ) {
    	global $post;
    	$terms = wp_get_post_terms( $post->ID, 'product_cat', $args );
    	$count = count($terms);
    	if(!empty($terms)) {
    		echo '<div class="product_categories minor_meta">Product Category: ';
    		for ($i = 0; $i < $count; $i++) {
    			//var_dump($terms[$i]);
    		   echo $terms[$i]->name;
    
    		   if ($i < ($count - 1)) {
    		      echo ', ';
    		   }
    		}
    		echo '</div>';
    	}
    }
    add_action( 'woocommerce_after_shop_loop_item_title', 'ava_woocommerce_after_shop_loop_item_title', 10, 2 );
    

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.