wp_create_tag() WordPress Function

The wp_create_tag() function allows you to create a new tag within Wordpress. This function takes two parameters: the name of the tag, and the slug for the tag. The name of the tag is the name that will be displayed for the tag, while the slug is the URL-friendly version of the name.

wp_create_tag( int|string $tag_name ) #

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


Parameters

$tag_name

(int|string)(Required)


Top ↑

Return

(array|WP_Error)


Top ↑

Source

File: wp-admin/includes/taxonomy.php

function wp_create_tag( $tag_name ) {
	return wp_create_term( $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.