The given tags are checked against the post's tags' term_ids, names and slugs.Tags given as integers will only be checked against the post's tags' term_ids. If no tags are given, determines if post has any tags. For more information on this and similar theme functions, check out the <a href="https://developer.wordpress.org/themes/basics/conditional-tags/">https://developer.wordpress.org/themes/basics/conditional-tags/</a> Conditional Tags article in the Theme Developer Handbook.
Parameters
$tagstring|int|arrayoptional
The tag name/term_id/slug, or an array of them to check for. Default empty.Default: ''
$postint|WP_Postoptional
Post to check. Defaults to the current post.Default: null
Return
bool
True if the current post has any of the given tags (or any tag, if no tag specified). False otherwise.
Uses · 1
has_term()Checks if the current post has any of given terms.
Signature, return type and hooks compared across 5 parsed releases.
7.0.4
Parameter $post retyped from int|WP_Post to int|WP_Post|null.verified against source
2.7.0
Can be used outside of the WordPress Loop if $post is provided.from the docblock
2.7.0
Tags given as integers are only checked against the post's tags' term_ids, not names or slugs.from the docblock
2.6.0
Introduced.from the docblock
About this page
Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/category-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.