在我的archive.php中,我试图添加一条仅显示在ID 148和子类别的特定类别上的消息。
下面的代码以某种方式工作,除了它在父类别上显示消息3次(与子类别相同)。
谢谢
$catTerms = get_terms('product_cat', array(
'hide_empty' => 0,
'orderby' => 'ASC',
'child_of'=>'148', ));
foreach($catTerms as $catTerm) :
if (is_product_category( $catTerm )) {
echo 'TEXT ONLY ON THE ARCHIVE OF THE PARENT CATEGORY WITH ID 148 and ITS CHILD CATEGORIES ';
}
endforeach;
?>