首页 WordPress函数大全 has_category()

has_category()

2020-05-02 / 4360阅 / 悠然

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

has_category( string|int|array $category = '', int|object $post = null )

Check if the current post has any of given category.

描述

参数

$category

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

Default value: ''

$post

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

Default value: null

返回

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

大家谈论
    我的见解