WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Listing random articles by Co-author in author box (3 posts)

  1. emadakn
    Member
    Posted 1 year ago #

    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
    	wp_reset_query();
    
    $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()) :
    
    	// 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>';
    	endwhile;
    	wp_reset_query();
    	$author_box .= '</ul>';
    	$author_box .= '</div>';
    	$content = $author_box.$content;
    	return $content;
    
    	endif;
    
    }
    
    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.

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

  2. emadakn
    Member
    Posted 1 year ago #

    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>
  3. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic