Pagination not working wit custom Query

Question

I have created a custom Query that works perfectly with my custom post type, inside this custom post type I’m showing an archive with other custom post types: One is a city, and inside each city there will be shown the stores inside this city.

THE PROBLEM

When trying to apply some pagination (I do not want to show 100 stores right away, but groups of 15), but when trying any function or guide to do this nothing is appearing.

<div class="division-ville-fripes-map loopside-villes">
    <ul id="container">
<?php 

$villeshow = get_the_title();
        
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1; 

$custom_query_args = array('post_type' => 'store', 
                  'orderby' => 'meta_value', 
                  'order'   => 'DESC', 
                  'posts_per_page' => 15, 
                  'paged'          => $paged,
                  'meta_key' => 'store_client_type' ,
                  'meta_query'  =>  array( 
      array( 
        'key' => 'store_city', 
        'value' => $villeshow, 
         ),
     ));
        $loop = new WP_Query( $custom_query_args );

        if(have_posts() ):

        while($loop->have_posts()):  $loop->the_post(); ?>
            
            <li>...stuff...</li>

    <?php
    endwhile;   
    endif;

    next_posts_link( __( 'Older Entries', 'textdomain' ), $loop->max_num_pages );
    previous_posts_link( __( 'Newer Entries', 'textdomain' ) );
 
    wp_reset_postdata(); 
        wp_reset_query();

            ?>
    
            </ul>
</div>
0
Cheo Molina 2 months 0 Answers 6 views 0

Leave an answer