wp_create_tag

Add a new tag to the database if it does not already exist.

Description

(array|WP_Error) wp_create_tag( (string) $tag_name ); 

Returns (array|WP_Error)

Parameters (1)

0. $tag_name (string)
The tag name.

Usage

  1. if ( !function_exists( 'wp_create_tag' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/taxonomy.php'; 
  3.  
  4. // The tag name. 
  5. $tag_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_create_tag($tag_name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/taxonomy.php  
  1. function wp_create_tag($tag_name) { 
  2. return wp_create_term( $tag_name, 'post_tag');