Rainer Lanemann
Rainer Lanemann

Reputation: 123

Can't put WooCommerce category description under a category box

I' trying to output WooCommerce category description on every category in their archive page. I managed to do this in theme WooCommerce template but I would like to make it possible in functions.php also.

At the moment it's like this:

    // Short text under a category box on archive page
function desc_cat_funct() {
   // trying to get a category information
    $desc_cat = category_description($category);
   // some css
    $desc_cat_res = '<span class="cat-info">'.$desc_cat.'</span>';
   // trying to output but kaput...
    echo $desc_cat_res;
}
add_action( 'woocommerce_after_subcategory', 'desc_cat_funct');

This outputs only html but not php info inside it. How could I make php show or echo the right output?

Upvotes: 1

Views: 150

Answers (1)

mujuonly
mujuonly

Reputation: 11861

    // Short text under a category box on archive page
function desc_cat_funct($category) {
   // trying to get a category information
    $desc_cat = category_description($category);
   // some css
    $desc_cat_res = '<span class="cat-info">'.$desc_cat.'</span>';
   // trying to output but kaput...
    echo $desc_cat_res;
}
add_action( 'woocommerce_after_subcategory', 'desc_cat_funct');

Upvotes: 1

Related Questions