Support » Plugin: Co-Authors Plus » Listing random articles by Co-author in author box

  • Resolved emadakn


    I want to list random articles under the author box by the current co-author. It works fine with normal users but not with Guest/Co-author user profiles.

    Here’s the code.

    // make globals and reset query first
    $coauthors = get_coauthors();
    foreach( $coauthors as $coauthor ):
    	$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()) :
    	// display (if results)
    	$author_box = '';
    	$author_box .= '<div class="post-author">';
    	$author_box .= '<div class="post-author-box">';
    	$author_box .= '<div class="post-author-img">'.get_avatar($coauthor->user_email, $size = '32').'</div>';
    	$author_box .= '<div class="post-author-info"><span class="edited">'.__('Edited by','news').'</span><span class="editor"><a href="'. get_author_link(false, $coauthor->ID, $coauthor->user_nicename).'">'.$coauthor->display_name.'</a></span></div><div class="clear"></div>';
    	$author_box .= '</div>';
    	$author_box .= '<ul>';
    	$author_box .= '<li class="author-info"><span style="font-style:italic;"> '.$coauthor->description.' </span></li>';
    	$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>';
    	$author_box .= '</ul>';
    	$author_box .= '</div>';
    	$content = $author_box.$content;
    	return $content;
    function poststats($content) {

    The other issue I’m facing is that for some reasons I cant get this code to output the co-author display name.

    <p class="before_story"><?php dt_photos_number(); ?><?php printf(__('By <span>%1$s</span> - %2$s','news'), get_the_author_meta('display_name'), get_the_time('D M d, g:i a')); ?></p>

    Im a new dummy here and not very good with php. Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Listing random articles by Co-author in author box’ is closed to new replies.