Echo author ID in author.php

Try this code.

$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
echo $author->ID;

Alternatively, if author name has not been set use:

if ( $author_id = get_query_var( 'author' ) ) { $author = get_user_by( 'id', $author_id ); }

credit @AndyAdams in the easily missed comments bellow

Leave a Comment

techhipbettruvabetnorabahisbahis forumutaraftarium24eduedueduedusedueduedusedusedusedus