Reputation: 123
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
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