Get author ID of a post in wordpress Get author ID of a post in wordpress wordpress wordpress

Get author ID of a post in wordpress


Try with this :

<?php $author_id=$post->post_author; ?>

it will give you current author id.

or this one will helps you more:

global $current_user;get_currentuserinfo();                      $args = array(    'author'        =>  $current_user->ID, // I could also use $user_ID, right?            );// get his posts 'ASC'$current_user_posts = get_posts( $args );

Thanks.


<?php the_author_meta( 'ID' ); ?>

Is probably better.

Ref: the_author_meta


On an author archive the following will get the author ID:

$author_ID = get_query_var('author');

This will get you a lot more information:

$pageobj = get_queried_object();

Reference:

http://codex.wordpress.org/Function_Reference/get_query_var
http://codex.wordpress.org/Function_Reference/get_queried_object