Or even the author id from the post id. I am trying to return the author meta (author page link and avatar) in the sidebar of a single post page (outside of the post loop). What is the best way to do this? I am using a custom function (see below) to return the post id, but am not sure what function to call next.
function this_post_id() {
global $wp_query;
$thePostID = $wp_query->post->ID;
return $thePostID;
}
I figured it out.
If you want it outside of loop then use the below code.
Valid values for the
$field
parameter include:This should work
Note: You need to use this function inside the loop.