How to Get query_posts from two 'meta_value' in infinite scroll Wordpress

75 Views Asked by At

I am trying to get post by two meta value key, and is working fine in normal page but is not working on infinity. The problem is that, there is no post request received when the page is scrolled.

Please see the code below. I have done many search on Google but I did not get any answer please help

function wp_infinitepaginate(){
$args = array( 
    'cat' => $cats,
   'meta_query' => array(
    'relation' => 'AND',
    array(
        'value' => 'India'
    ),
    array(
        'value' => 'Hindi'
    ), 
  )
);
$query = new WP_Query( $args ); ?>
 <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
     <div class="art" >
    <a class="title" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
    </div>
    <?php endwhile; else : ?>
        <p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; 
        exit;
    }
    add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate');  
    add_action('wp_ajax_nopriv_infinite_scroll', 'wp_infinitepaginate');    
0

There are 0 best solutions below