wp_create_tag( int|string $tag_name ): array|WP_Error

In this article

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

Parameters

$tag_nameint|stringrequired

Return

array|WP_Error

Source

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