Monday, December 8, 2014

How to set default tags for post in wordpress



Out today's topics is how to set default tags for post in wordpress. To set default tags for post we can create a plugin or we can write function in wordpress theme function.php file. We can write a function for this 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. 

0 comments :

Post a Comment

 

Copyright @ 2014 Tech Tutorial .