所以我回应了一系列帖子作为标题。每个帖子属于一个特定的类别和子类别,以便使用这些标题从该标题所属的子类别中加载ajax的所有帖子。我需要回显每个标题的子类别的id。请帮忙! :)
foreach((get_the_category($post->ID)) as $childcat) {
echo $childcat->cat_name . '</a>';
}
if you have some key for subcategories, You can classify categories as below.
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(10, $childcat)) {
echo $childcat->cat_name . '</a>';
}
}