tag_exists() WordPress Function

The tag_exists() function is used to check if a given tag already exists. It accepts two parameters: the tag name and the taxonomy name. If the tag exists, it will return true. Otherwise, it will return false.

tag_exists( int|string $tag_name ) #

Check whether a post tag with a given name exists.


Parameters

$tag_name

(int|string)(Required)


Top ↑

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.


Top ↑

Source

File: wp-admin/includes/taxonomy.php

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


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.