现在的位置: 首页WordPress>正文
wordpress的category_description  
发表于527 天前 WordPress 暂无评论

wordpress的category_description函数根据分类的ID,得到分类的描述。

category_description函数常和echo、get_the_category()配合使用,例如:
echo category_description(get_the_category()->cat_ID)

get_the_category()得到保存有当前分类信息的一个数组;cat_ID为该数组中该分类的ID;将该ID输入给category_description()函数,即可得到该分类的描述;然后使用echo将其输出。
使用如下的语句可以实现和上面语句相同的功能:
echo category_description()

为什么呢?

可能是因为category_description函数在默认无参数的情况下会输出当前分类描述的结果吧。

给我留言


/ 快捷键:Ctrl+Enter
不想听你唠叨×