Checks if the current post has any of given tags.
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 Conditional Tags article in the Theme Developer Handbook.
$tagstring|int|arrayoptional
Default:''
$postint|WP_Postoptional
Default:null
function has_tag( $tag = '', $post = null ) {
return has_term( $tag, 'post_tag', $post );
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/has_tag