【发布时间】:2021-01-07 02:57:20
【问题描述】:
我想检查 Wordpress 帖子是否有类别“X、Y 或 Z”,如果有,则显示类别的名称(“X Y 或 Z”)。
我已经检查并获得了该类别的真实性,但是如何显示在_category() 中找到的每个名称;
if ( in_category( array( 'X', 'Y', 'Z') {
echo "yes";
}
如何显示类别名称?
【问题讨论】:
-
尝试使用get_the_category(int $post_id)函数
-
试过了,给了我一个“意外的'$post_id' (T_VARIABLE),期待')'”