Get Author for Single Post in Custom Post Type

I have looked high and low for an answer to this question and all I keep finding is how to make an archive page that list all authors and their post (including cpt’s). I’ve tried to adapt these pages, but I still can’t get just the author of a single post that happens to be in a custom post type.

I just simply want to get the author of the current post which happens to be in a custom post type, which for one reason or another seems to be just about impossible.

Read More

Can somebody please, please, please hook me up with a function or anything that can just simply get the author of the current post that happens to be in a custom post type.

Related posts

1 comment

  1. There are several functions for this available, like: the_author, for displaying; get_the_author, for returning. There is no restriction regarding custom post types, but those template tags only work inside the loop.
    If you want to get more author information then the name you can use: the_author_meta, displaying; get_the_author_meta, returning. The latter two functions can also be used for getting author information outside the loop, for this you have to specify the second parameter $userID, which inside the loop isn’t necessary. A basic example for this would be going like this:

    global $post;
    $a_id=$post->post_author;
    the_author_meta( 'user_nicename', $a_id );
    

    Take a look at this question and the answers for more outside the loop use cases.

Comments are closed.