Support » Plugin: Co-Authors Plus » Possible WP_query()?

  • Resolved emadakn

    (@emadakn)


    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/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    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' ));

    Thanks a lot Daniel!
    It worked.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Possible WP_query()?’ is closed to new replies.