has_tag

Definition:
function has_tag( $tag = '', $post = null ) {}

Check 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.

Parameters

  • string|int|array $tag: Optional. The tag name/term_id/slug or array of them to check for.
  • int|object $post: Optional. Post to check instead of the current post. (since 2.7.0)

Return values

returns:True if the current post has any of the given tags (or any tag, if no tag specified).

Source code

function has_tag( $tag = '', $post = null ) {

	return has_term( $tag, 'post_tag', $post );

}

1939

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: