我怀疑the Codex information for has_term()
不正确:
<?php has_term( $term, $taxonomy, $post ) ?>
对于
$taxonomy
参数:
$分类法(字符串)(可选)分类法名称默认值:“”
但是如果你看the source for has_term()
:
$r = is_object_in_term( $post->ID, $taxonomy, $term );
所以,
$taxonomy
已传递给
is_object_in_term()
:
<?php is_object_in_term( $object_id, $taxonomy, $terms = null ) ?>
这说明
$taxonomy
参数:
$分类法(字符串)(必需)单个分类法名称。默认值:无
(一看source for is_object_in_term()
确认$taxonomy
参数是必需的,并将导致返回false
如果未通过。)
因此,似乎未能通过$taxonomy
到has_term()
将导致has_term()
正在返回false
.
似乎源内联文档已相应更新:
* @param string|int|array $term Optional. The term name/term_id/slug or array of them to check for.
* @param string $taxonomy Taxonomy name
* @param int|object $post Optional. Post to check instead of the current post.
* @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
The
$taxonomy
参数不再列为
Optional
.