Title: Query Post Author
Last modified: January 8, 2018

---

# Query Post Author

 *  [baidoc](https://wordpress.org/support/users/baidoc/)
 * (@baidoc)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/query-post-author/)
 * Hello,
 * I’m trying to implement the infinite scroll into my author.php page where I have
   3 query_posts.
 * They are all the same, the only difference is the ‘orderby’ parameter.
 * This is how I’ve been trying to integrate the plugin into my code:
 *     ```
       <?php
         query_posts(array('author' => $author, 'orderby' => 'comment_count', 'posts_per_page' => '5'));
         if ( have_posts() ) : while ( have_posts() ) : the_post();
       ?>
   
       <article>
       <figure>
       <?php echo get_the_post_thumbnail($post_id); ?>
       </figure>
       <div class="entry-body">
       <h3><?php the_title(); ?></h3>
       </div>
       </article>
   
       <?php endwhile; else: ?>
       <p><?php _e('No Posts to show!'); ?></p>
       <?php endif; ?>
   
       <?php echo do_shortcode('[ajax_load_more]'); ?>
       ```
   
 * What am I doing wrong?

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/query-post-author/#post-9844117)
 * Hi [@baidoc](https://wordpress.org/support/users/baidoc/),
    Here is a code samples
   for use with author archives. [https://connekthq.com/plugins/ajax-load-more/docs/code-samples/author-archives/](https://connekthq.com/plugins/ajax-load-more/docs/code-samples/author-archives/)
 * You need to pass the author ID to ajax load more.
 *  Thread Starter [baidoc](https://wordpress.org/support/users/baidoc/)
 * (@baidoc)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/query-post-author/#post-9846907)
 * Thank you, that has worked.
 * Now I’m having another issue with the custom parameter.
 * I’ve the following query (which works)
 *     ```
       $args = array(
       	'author' 		=> $author,
       	'post_type' 	=> 'post',
       	'posts_per_page'=> 3,
       	//'order' 		=> 'ASC',
       	'orderby'   	=> 'meta_value_num',
       	'meta_key'  	=> '_post_like_count'
       );
       $like_query = new WP_Query( $args );
       if ( $like_query->have_posts() ) : 
       	while ( $like_query->have_posts() ) : $like_query->the_post();
       ..
       ```
   
 * How would I integrate it with the Infinite Scroll?
 * Tried this method:
    `[ajax_load_more ... meta_key="meta_key" meta_value="_post_like_count"
   meta_compare="IN" ...]`
 * Also tried this:
 * `[ajax_load_more ... custom_args="meta_key:_post_like_count;orderby:meta_value_num"...]`
 * None from above seem to work.
 * Any idea why?
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/query-post-author/#post-9847554)
 * Hi [@baidoc](https://wordpress.org/support/users/baidoc/),
    You were close with
   the first try.
 * Assuming you just want to order by the `_post_like_count` meta key
    `[ajax_load_more
   meta_key="_post_like_count" orderby="meta_value_num"]`
 *  Thread Starter [baidoc](https://wordpress.org/support/users/baidoc/)
 * (@baidoc)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/query-post-author/#post-9854252)
 * It doesn’t return anything. Is there a way to see logs, or why it won’t return
   anything?
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/query-post-author/#post-9855178)
 * Nothing will be logged.
    Your meta_key must be incorrect.
 * Can you explain exactly what you are trying to do. Maybe i’m missing something.
 *  Thread Starter [baidoc](https://wordpress.org/support/users/baidoc/)
 * (@baidoc)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9858042)
 * Thank you for the reply.
 * I’ve the following script integrated in my WordPress: [https://hofmannsven.com/2013/laboratory/wordpress-post-like-system/](https://hofmannsven.com/2013/laboratory/wordpress-post-like-system/)
 * Basically it’s just a post like script, where anyone can like any post.
 * The Meta key for this script is: `'meta_key' => '_post_like_count'`
 * I’m just trying to fetch user’s liked posts using your plugin but it doesn’t 
   seem to work.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9858697)
 * Ok. On that case you need to also pass in the other meta parameters for a complete
   meta query. I thought you were only ordering by the field.
 * `meta_key=“_post_like_count” meta_compare=“=“ meta_type=“CHAR”`
 * You might need to play around with the type and compare parameters. Hope that
   helps.
 *  Thread Starter [baidoc](https://wordpress.org/support/users/baidoc/)
 * (@baidoc)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9858824)
 * I don’t know why, but still can’t figure it out, and won’t work.
 * Also, from where did you get the meta_compare? I can’t see it anywhere on the
   shortcode builder page.
 * I also tried:
    [ajax_load_more post_type=”post” author=”‘.$author.'” meta_key
   =”meta_key:orderby” meta_value=”_post_like_count:meta_value_num” meta_compare
   =”IN:IN” meta_type=”CHAR:CHAR” meta_relation=”AND”]
 * or:
 * [ajax_load_more post_type=”post” author=”‘.$author.'” meta_key=”:orderby” meta_value
   =”_post_like_count:meta_value_num” meta_compare=”IN:IN” meta_type=”CHAR:CHAR”
   meta_relation=”AND” orderby=”name”]
 * What else could I try?
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9858849)
 * meta compare is Meta Operator I think in the shortcode builder.
 * Open a ticket here if you want me to log in and try tix the issue for you.
 *  [https://connekthq.com/plugins/ajax-load-more/support/](https://connekthq.com/plugins/ajax-load-more/support/)
 *  Thread Starter [baidoc](https://wordpress.org/support/users/baidoc/)
 * (@baidoc)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9864704)
 * Hi,
 * While preparing the Ticket for you and the page to send you, I noticed that it
   works when I insert directly through wp-admin (directly embedded into page)
 * BUT if I try using the do_shortcode function it won’t work.
 * What could be the reason for that? Should I still open the ticket?
 * Thank you!
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9865613)
 * A reason could be that there is already a loop on the page and it’s inferring
   with the Ajax query.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Query Post Author’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

## Tags

 * [author](https://wordpress.org/support/topic-tag/author/)

 * 11 replies
 * 2 participants
 * Last reply from: [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/query-post-author/#post-9865613)
 * Status: not resolved