i want to make a plugin that adds a tag to a post automatically
my code (example):
add_action('save_post', 'agregar_tags');
function agregar_tags($id){
$tags=array('A tag','Another tag');
wp_set_post_tags($id,$tags);
}
it only creates the tags, but they aren't assigned to the post, the post says 'No tags'.
What can i do to create the tags and asign them to the post, i thought that wp_set_post_tags() can do that
thank you
p.d: also tried wp_set_object_terms() and nothing