0

I've recently installed the Co-Authors Plus plugin and am trying to get all the authors from a post within a post loop. However for some reason when I use get_queried_object(), there is only one author listed not multiple.

Is there a way to get all the authors from a post using WP_Query or some other manner?

  • Do you mean all authors? – Gufran Hasan Nov 12 '18 at 10:24
  • No, I mean all the authors from that one post, so if I add 2 users to the post e.g. Admin and myself, I want to be able to get both admin and myself in another wordpress loop e.g. archive page with a WP_Query – ParadAUX Nov 12 '18 at 10:27
  • 1
    @GufranHasan Please stop misusing code markup. Thank you. – fuxia Nov 12 '18 at 15:35
  • @fuxia, Okay thanks, I will take care it next time :) – Gufran Hasan Nov 12 '18 at 15:37
0

If you are using Co-Authors Plus plugin. By default, it will show the original author of the post.

You’ll need to edit theme files with the code responsible for showing the author name for posts. This could be single.php, content.php, or a template tag in your theme’s functions.php file.

the_author_posts_link() and you will need to replace it with the following code snippet.

if ( function_exists( 'coauthors_posts_links' ) ) {
    coauthors_posts_links();
} else {
    the_author_posts_link();
}

Reference

You can use the following code to get co-authors.

<?php $coauthors = get_coauthors(); ?>
<?php foreach( $coauthors as $coauthor ): ?>
<center><div class="authbio">
<img src="<?php bloginfo('template_url'); ?>/images/<?php echo $coauthor->user_firstname; ?>.jpg" alt="" class="alignleft"/>
<?php $userdata = get_userdata( $coauthor->ID ); ?>
<?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
</div></center>
<?php endforeach; ?>
  • Thanks, but I'm not trying to show the authors in the content. As I've stated, I want to get the all of the authors from one page. So if I add 2 authors to the about-us page, I want to be able to WP_Query those 2 authors, currently I only get 1 author back, which is the author that is at the top of the list. – ParadAUX Nov 12 '18 at 10:46
  • Please see this link stackoverflow.com/questions/32805028/… – Gufran Hasan Nov 12 '18 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.