• Hi,

    How can I get the co-authors’ posts listed on author.php for a custom post type? At the moment, the post appears listed only in the first author’s profile, but not in their co-authors’ profiles.

    Here’s my code.

    <?php
        $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($coauthor));
    $args = array(
    	'author' => $author,
        'posts_per_page' => -1,
        'post_type' => 'bookshelf',
    	'post_status' => 'publish',
    
    );
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    if ( $the_query->have_posts() ) {
    echo '<div class="masonry-item"><h2>Bookshelf</h2>';
    echo '<ul>';
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
    echo '<li>';
                echo '<a href="'.get_permalink().'">'.get_the_title().'</a>';
                echo '</li>';
        }
    echo '</ul></div>';
    } else {
        // no posts found
    }
    
    wp_reset_postdata();
    ?>

    What am I doing wrong? Please help!

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Ismael Latorre

    (@miguelripoll)

    I also tried this, but doesn’t work at all. Does anybody know how to solve this issue? It seems no-one at Auttomatic is supporting this plugin here…

    <?php
    
    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'bookshelf',
        'post_status' => 'publish',
        'tax_query' => array( // Query on the "Co-Authors Plus" custom taxonomy
            array(
                'taxonomy' => 'author',
                'terms' => $author // the author ID
            )
        )
    );
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    if ( $the_query->have_posts() ) {
        echo '<div class="masonry-item"><h2>Bookshelf</h2>';
        echo '<ul>';
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            echo '<li>';
            echo '<a href="'.get_permalink().'">'.get_the_title().'</a>';
            echo '</li>';
        }
        echo '</ul></div>';
    }
    
    wp_reset_postdata();
    
    ?>

    I had a very similar issue, still looking for a resolution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘author.php not listing co-author's posts’ is closed to new replies.