我试图在其归档页面的每个类别上输出WooCommerce类别描述。我设法在主题WooCommerce模板中做到了这一点,但我也想在functions.php中实现它。
目前是这样的:
// 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');
这仅输出html而不显示其中的php信息。如何使php显示或回显正确的输出?
答案 0 :(得分:1)
// 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');