Summery Summery
Check if the current post has any of given terms.
Syntax Syntax
Description Description
The given terms are checked against the post’s terms’ term_ids, names and slugs. Terms given as integers will only be checked against the post’s terms’ term_ids. If no terms are given, determines if post has any terms.
Parameters Parameters
- $term
-
(Optional) The term name/term_id/slug or array of them to check for.
Default value: ''
- $taxonomy
-
(Optional) Taxonomy name
Default value: ''
- $post
-
(Optional) Post to check instead of the current post.
Default value: null
Return Return
(bool) True if the current post has any of the given tags (or any tag, if no tag specified).
Source Source
File: wp-includes/category-template.php
* * If no categories are given, determines if post has any categories. * * @since 3.1.0 * * @param string|int|array $category Optional. The category name/term_id/slug, * or an array of them to check for. Default empty. * @param int|object $post Optional. Post to check instead of the current post. * @return bool True if the current post has any of the given categories * (or any category, if no category specified). False otherwise. */ function has_category( $category = '', $post = null ) { return has_term( $category, 'category', $post ); }
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |