Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一个WordPress函数来检查一个类别是否是另一个类别的子类别,例如cat_is_ancestor_of().
WordPress
cat_is_ancestor_of()
任何人都可以帮忙吗?
你可以试试这个
function category_has_parent($catid){ $category = get_category($catid); if ($category->category_parent > 0){ return true; } return false; }
如下使用它
if(category_has_parent('5')) // 5 is the category id { echo "it has a parent !"; }