WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. lsterling03
    Member
    Posted 7 months 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:

    <?php
    	$authors = $wpdb->get_results("SELECT ID
    	FROM $wpdb->users
    	WHERE EXISTS
    	(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 } ?>

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

Reply

You must log in to post.

About this Plugin

About this Topic