Co-Authors Plus
Query only shows first author (1 post)

  1. lsterling03
    Posted 2 years ago #

    I have a page that is displaying all authors and their posts (within a custom post type). For example:

    John Doe
    - Post 1
    - Post 2

    Jane Doe
    - Post 1
    - Post 2 ...

    However, for posts that belong to multiple authors, the post only shows up in the list for the author that is in first position. If I drag the 2nd author to first position, then the article shows up for that author instead.

    Here is my code to display authors and their posts all on one page:

    	$authors = $wpdb->get_results("SELECT ID
    	FROM $wpdb->users
    	(SELECT post_author
    	FROM $wpdb->posts
    	WHERE $wpdb->users.ID = $wpdb->posts.post_author
    	AND $wpdb->posts.post_status = 'publish'
    	AND $wpdb->posts.post_type = 'publication'
    	ORDER BY display_name");
    	foreach($authors as $author) {
    	$curauth = get_userdata(intval($author->ID));
            <h2><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></h2>
            <?php query_posts( array( 'post_type' => 'publication', 'showposts' => -1, 'author'=>$author->ID ) ); while (have_posts()) : the_post(); ?>
            <?php the_content(); ?>
            <?php endwhile; ?>
    <?php } ?>


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Co-Authors Plus
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic