Core Function
View Source on Trac ↗ in_category()
in_category( mixed $category, mixed $post = null ) Checks if the current post is within any of the given categories.
Parameters 2 required
| Name / Type | Description |
|---|---|
| mixed | (int | string | int[] | string[]) $category Category ID, name, slug, or array of such to check against. Required |
| (int | | WP_Post) $post Optional. Post to check. Defaults to the current post. Required |
Return Value
(bool)
True if the current post is in any of the given categories.
Function Information
Since Version
1.2.0
Source File
wp-includes/category-template.php
Advertisement