How to set default tags for post in wordpress

Mahabubur Rahman
0



Our today's topics are how to set default tags for the post in WordPress. To set default tags for posts we can create a plugin or we can write a function in the WordPress theme function.php file. We can write a function for these topics as following - 

add_action('publish_post','add_default_tags');
function add_default_tags(){
$postId=get_the_ID();
$tags=array('Programming','Tutorial');
wp_set_post_tags($postId,$tags,true);
}
Update function.php or if you write a plugin then active it.

Now write a post and publish it then see it automatically add those tags. 

Post a Comment

0Comments
Post a Comment (0)