Title: wp_create_tag
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_create_tag( int|string $tag_name ): array|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#parameters)󠁿

 `$tag_name`int|stringrequired

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#return)󠁿

 array|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#source)󠁿

    ```php
    function wp_create_tag( $tag_name ) {
    	return wp_create_term( $tag_name, 'post_tag' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/taxonomy.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/taxonomy.php#L234)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/taxonomy.php#L234-L236)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_create_term()](https://developer.wordpress.org/reference/functions/wp_create_term/)`wp-admin/includes/taxonomy.php` |

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

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_create_tag/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.3.0](https://developer.wordpress.org/reference/since/2.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_create_tag%2F)
before being able to contribute a note or feedback.