Automatically add author’s name to post_tag

Check get_the_author()

(Note:This tag must be used within The Loop.)

you code may be like this
In functions.php:

add_action( 'save_post', 'add_authors_name');
 function add_authors_name( $post_id ) {
 global $post;
 $post_author = $post->post_author;  // returns the Author ID
 // get the author's WP_User object so we can get the Author Name
 $post_author_obj = get_userdata( $post_author );
 $post_author_name = $post_author_obj->first_name . ' ' . $post_author_obj->last_name;
 wp_set_post_terms( $post_id, $post_author_name, 'post_tag', true );
 }

Leave a Comment