Core Function
View Source on Trac ↗ has_term()
has_term( mixed $term = '', mixed $taxonomy = '', mixed $post = null ) Checks if the current post has any of given terms.
Parameters 2 required
| Name / Type | Description |
|---|---|
| mixed | (string | int | array) $term Optional. The term name/term_id/slug, or an array of them to check for. Default empty. Required |
| $taxonomy string | Optional. Taxonomy name. Default empty. |
| (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 terms
(or any term, if no term specified). False otherwise.
Function Information
Since Version
3.1.0
Source File
wp-includes/category-template.php
Advertisement