wp-content » plugins » How to Automatically Create Post Tags from Post Title

How to Automatically Create Post Tags from Post Title

Here is a simple WordPress plugin that will automatically add tags from the post title when saving posts.

chrome cCDdNjvuEJ - How to Automatically Create Post Tags from Post Title
<?php
/**
 * Plugin Name: Auto Tag
 * Description: Automatically creates tags from the post title and assigns them to the post.
 * Version: 1.0
 * Author: Stefan Pejcic
 */

function auto_tag_from_title($post_id) {
  $post_title = get_the_title($post_id);
  $tags = explode(" ", $post_title);

  wp_set_post_tags($post_id, $tags, true);
}
add_action('save_post', 'auto_tag_from_title');

To use this plugin, simply copy and paste the code into a new file and save it as auto-tag.php in the wp-content/plugins directory of your WordPress site. Then, go to the Plugins page in the WordPress admin dashboard and activate the plugin. Every time a post is saved, the plugin will automatically create tags from the post title and assign them to the post.

See also  How to remove the Remember Me option from WordPress login page

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended