我需要知道当前的分类法是子分类法还是父分类法。我怎样才能做到这一点?
我需要它作为if语句中的条件。我需要知道
if(this is child taxonomy){
}
有人知道怎么做吗?我需要知道当前的分类法是子分类法还是父分类法。我怎样才能做到这一点?
我需要它作为if语句中的条件。我需要知道
if(this is child taxonomy){
}
有人知道怎么做吗?您可能正在使用这段代码,可以在WordPress支持文章中找到,您可以看到here.
Use get_ancestors()
.
$ancestors = get_ancestors( 4, \'category\' );
// var_dump($ancestors); // debugging
if (!empty($ancestors)) {
// category 4 is a child of some other category
} else {
// category 4 is not a child. It is "top-level" in the hierarchy.
}
我正在使用wp\\u list\\u categories()显示我的所有类别。但我希望子类别链接到该类别的最后一个帖子。例如: <ul> <li><a href=\"link-to-category-1\">CATEGORY 1</a> <ul> <li><a href=\"link-to-last-post-of-category-1-1\">CATE