tag_exists( int|string $tag_name ): mixed

In this article

Checks whether a post tag with a given name exists.

Parameters

$tag_nameint|stringrequired

Return

mixed Returns null if the term does not exist.
Returns an array of the term ID and the term taxonomy ID if the pairing exists.
Returns 0 if term ID 0 is passed to the function.

Source

function tag_exists( $tag_name ) {
	return term_exists( $tag_name, 'post_tag' );
}

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.