jcadima
2/24/2017 - 8:10 PM

Woocommerce get Category Name AND Description in archives template

Woocommerce get Category Name AND Description in archives template

http://stackoverflow.com/questions/21419138/how-to-display-category-name-of-the-woocomerce-product-in-wordpress-theme-header

<?php

// TO GET ONLY THE CATEGORY NAME:
global $post;

// GET CATEGORY NAME
$args = array( 'taxonomy' => 'product_cat',);
$terms = wp_get_post_terms($post->ID,'product_cat', $args);

<h1><?php  echo $terms[0]->name ; ;  ?></h1>

=============================================================================================
<?php
// This gets the Category description and Category name In Woocommerce > Categories
global $post;
$args = array( 'taxonomy' => 'product_cat',);
$terms = wp_get_post_terms($post->ID,'product_cat', $args);

$count = count($terms); 
if ($count > 0) {

    foreach ($terms as $term) {
        echo '<div style="direction:rtl;">';
        echo $term->description; // GETS DESCRIPTION
        echo $term->name; // GETS NAME
        echo '</div>';

    }

}