Skip to content

Instantly share code, notes, and snippets.

@nciske
Last active April 6, 2019 07:43
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nciske/5885607 to your computer and use it in GitHub Desktop.
List just co-authors with thumbnail
<?php
$args = array( 'post_type' => 'guest-author', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' );
$guest_authors = get_posts( $args );
foreach( $guest_authors as $ga ){
echo '<div class="contributor">';
echo get_the_post_thumbnail( $ga->ID, 'thumbnail', array( 'class' => 'alignright' ) );
$username = get_post_meta( $ga->ID, 'cap-linked_account', true );
if( $username ){
$user = get_user_by( 'login', $username );
$url = get_author_posts_url( $user->ID, $user->user_nicename );
echo '<a href="'.$url.'"><h3>'.$ga->post_title.'</h3></a>';
}else{
echo '<h3>'.$ga->post_title.'</h3>';
}
echo '</div>';
}
@nciske
Copy link
Author

nciske commented Jun 28, 2013

@irenefdez
Copy link

Nice!
I have the list and the image, but not the link to author's page. Can you help me?

@stejus
Copy link

stejus commented Apr 6, 2019

Thanks, this works for me too! However, I would also like to display the guest author bio below respective names. Your help would be very much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment