如果我在一个模板上使用has_category('dogs')
,比如index.php、archive.php或search.php,并且循环中显示的其中一个帖子中有类别狗,函数会返回true吗?
我知道它在单个帖子上工作,但我需要知道它是否在循环中也能工作,而且任何一个帖子都有这个类别。
发布于 2019-06-11 21:35:47
只要在循环中使用has_category
,那么它在index.php
、archive.php
等中使用时就会工作。如果在这些模板上在循环之外使用它,您可能会遇到问题。
https://wordpress.stackexchange.com/questions/340225
复制相似问题