WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Possible WP_query()? (3 posts)

  1. emadakn
    Member
    Posted 1 year ago #

    Is there any way to display more articles by the co-author within author bio box?

    This is my code:

    $coauthors = get_coauthors();
    foreach( $coauthors as $coauthor ):
    endforeach;
    
    	$display = new WP_query();
    	$display->query(array('showposts' => 5, 'author' => get_the_author_meta('ID'), 'orderby' => 'rand' ));
    	global $wp_query; $wp_query->in_the_loop = true;
    	if ($display->have_posts()) :
    
    $author_box .= '<li class="read-also">'.__('Also Wrote','news').'</li>';
    	while ($display->have_posts()) : $display->the_post();
    	$author_box .= '<li><a href="'.get_permalink($post->ID).'">'.dt_get_posttype().get_the_title().'</a></li>';
    	endwhile;
    	wp_reset_query();
    	$author_box .= '</ul>';
    	$author_box .= '</div>';
    	$content = $author_box.$content;
    	return $content;
    
    	endif;

    I'm trying to get this to work from past few days but no luck.

    Any help would be appreciated.

    http://wordpress.org/extend/plugins/co-authors-plus/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Instead of:

    $display->query(array('showposts' => 5, 'author' => get_the_author_meta('ID'), 'orderby' => 'rand' ));

    You should be able to use:

    $display->query(array('showposts' => 5, 'author_name' => $coauthor->user_login, 'orderby' => 'rand' ));

  3. emadakn
    Member
    Posted 1 year ago #

    Thanks a lot Daniel!
    It worked.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic