Core Function
View Source on Trac ↗ has_category()
has_category( mixed $category = '', mixed $post = null ) Checks if the current post has any of given category.
Parameters 2 required
| Name / Type | Description |
|---|---|
| mixed | (string | int | array) $category Optional. The category name/term_id/slug, or an array of them to check for. Default empty. Required |
| (int | | WP_Post) $post Optional. Post to check. Defaults to the current post. Required |
Return Value
(bool)
bool True if the current post has any of the given categories
(or any category, if no category specified). False otherwise.
Function Information
Since Version
3.1.0
Source File
wp-includes/category-template.php
Advertisement