• I wrote a loop to display the posts assigned to the currently logged in user. However with this plugin, the loop only returns posts where the current user is the primary author. For example, if I assign two authors to one post, the second Author returns no posts. I confirmed this by changing the order of Authors using the plugin drag+drop interface.

    Here’s my loop:

    <ul>
    <?php
    if ( is_user_logged_in() ):
    
        global $current_user;
        get_currentuserinfo();
        $author_query = array('posts_per_page' => '-1','author' => $current_user->ID,'post_type' => 'residents');
        $author_posts = new WP_Query($author_query);
        while($author_posts->have_posts()) : $author_posts->the_post();
        ?>
            <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
        <?php           
        endwhile;
    
    else :
    
        echo "not logged in";
    
    endif;
    ?>
    </ul>
Viewing 5 replies - 1 through 5 (of 5 total)
  • i don’t know if anyone is still looking for this answer, but how I got it to work was this:

    ?php   $user_name = get_the_author_meta('user_login');
    		$args = array('post_type'=>array('product'),
        'tax_query' => array(
            array(
                'taxonomy' => 'author',
                'terms' => $user_name,
                'field' => 'name',
            )
        ),
        'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC');
    		        query_posts($args);
                      //the loop start here
                         if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    			 <table style="width:100%">
                     <tr style="border: none; ">
                        <th style="width:18%; border: none;" valign="top">
                           <?php echo the_post_thumbnail('thumbnail'); ?>
                        </th>
                       <th style="border: none;">
                            <a href="<?php echo get_permalink(); ?>"><?php echo the_title();?></a>
                       <br><br>
                        <?php the_excerpt();?>
                       </th>
                    </tr>
                </table> 

    I hope this helps someone

    Hi Kaye,

    I’m having the same issue as yourself. Posts will only show for the primary author.

    I’ve had a look at your solution and searched online on how to implement it.

    Could you tell me how you were able to get it working, please?

    Your time is much appreciated.

    Hi Kaye,

    I’ve made a new page template and included your code in there when I test the page, I get a blank page.

    Many thanks.

    <?php   $user_name = get_the_author_meta('user_login');
    		$args = array('post_type'=>array('product'),
        'tax_query' => array(
            array(
                'taxonomy' => 'author',
                'terms' => $user_name,
                'field' => 'name',
            )
        ),
        'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC');
    		        query_posts($args);
                      //the loop start here
                         if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    			 <table style="width:100%">
                     <tr style="border: none; ">
                        <th style="width:18%; border: none;" valign="top">
                           <?php echo the_post_thumbnail('thumbnail'); ?>
                        </th>
                       <th style="border: none;">
                            <a href="<?php echo get_permalink(); ?>"><?php echo the_title();?></a>
                       <br><br>
                        <?php the_excerpt();?>
                       </th>
                    </tr>
                </table> 

    I noticed there was a missing < at the beginning

    Thanks for the update Kaye,

    I did add the < at the beginning but it just wouldn’t work with my setup.

    I ended up using Bylines to achieve this, worked perfectly.

    All the best.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Loop Only Showing Primary Author’s Posts’ is closed to new replies.