public
Last active

List just co-authors with thumbnail

  • Download Gist
co-authors-list.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<?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>';
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.