How To Create WordPress Tag Programmatically

I would like to create a new WordPress tag from plugin programmatically. Which function should I call

You can use wp_insert_term function to create a new tag for “post_tag” taxonomy

wp_insert_term(
  'New Tag Name', // the term 
  'post_tag', // the taxonomy
  array(
    'description'=> 'Tag Desc.',
    'slug' => 'new-tag',
    'parent'=> $parent_term_id
  )
);
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments