• 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

    (@dcooney)

    Hi @baidoc,
    Here is a code samples for use with 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

    (@baidoc)

    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

    (@dcooney)

    Hi @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

    (@baidoc)

    It doesn’t return anything. Is there a way to see logs, or why it won’t return anything?

    Plugin Author Darren Cooney

    (@dcooney)

    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

    (@baidoc)

    Thank you for the reply.

    I’ve the following script integrated in my WordPress: 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

    (@dcooney)

    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

    (@baidoc)

    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

    (@dcooney)

    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/

    Thread Starter baidoc

    (@baidoc)

    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

    (@dcooney)

    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.