Current post’s author name in the author meta tag

You cad add it via functions.php with a hook, instead of inside the loop (you don’t really want to add a loop to header.php):

function add_author_meta() {

    if (is_single()){
        global $post;
        $author = get_the_author_meta('user_nicename', $post->post_author);
        echo "<meta name=\"author\" content=\"$author\">";
    }
}
add_action( 'wp_enqueue_scripts', 'add_author_meta' );

Leave a Comment