首页 WordPress函数大全 has_term()

has_term()

2020-05-02 / 5677阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

has_term( string|int|array $term = '', string $taxonomy = '', int|WP_Post $post = null )

Check if the current post has any of given terms.

描述

The given terms are checked against the post’s terms’ term_ids, names and slugs. Terms given as integers will>

参数

$term

(string|int|array)
(Optional)
The term name/term_id/slug or array of them to check for.

Default value: ''

$taxonomy

(string)
(Optional)
Taxonomy name.

Default value: ''

$post

(int|WP_Post)
(Optional)
Post to check instead of the current post.

Default value: null

返回

(bool) True if the current post has any of the given tags (or any tag, if no tag specified).

大家谈论
    我的见解