Home > Backend Development > PHP Tutorial > WordPress获取二级分类ID

WordPress获取二级分类ID

WBOY
Release: 2016-06-06 20:49:05
Original
1210 people have browsed it

现在我的WordPress有二级分类,比如,一级分类:A,子分类(二级分类):a,b。现在想在分类A的模板中,分别获得分类a,b的ID,并且判断出a,b的ID大小。

回复内容:

现在我的WordPress有二级分类,比如,一级分类:A,子分类(二级分类):a,b。现在想在分类A的模板中,分别获得分类a,b的ID,并且判断出a,b的ID大小。

可以使用

<code>get_term_children($term_id, $taxonomy)
</code>
Copy after login

函数获取,返回数组,包含$term_id下的所有子类。 至于判断大小,就只要循环数组比较大小就行了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template