首页 WordPress函数大全 in_category()

in_category()

2020-05-02 / 5162阅 / 悠然

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

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

Checks if the current post is within any of the given categories.

描述

The given categories are checked against the post’s categories’ term_ids, names and slugs. Categories given as integers will> Conditional Tags article in the Theme Developer Handbook.

参数

$category

(int|string|array)
(Required)
Category ID, name or slug, or array of said.

$post

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

Default value: null

返回

(bool) True if the current post is in any of the given categories.

大家谈论
    我的见解