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)
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
File: wp-admin/includes/taxonomy.php
function tag_exists( $tag_name ) { return term_exists( $tag_name, 'post_tag' ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |