0

I'm trying to add results with pagination to the main query results with custom arguments. But the problem is that I'm getting the second loop result in every pagination page. The goal is to add them to the end of list (last pagination pages). For example: - The first loop is getting 99 results and 10 pagination pages - The second loop is getting 21 results and listed as 100 to 120, starting from 10 pagination page to 12.

 <div class="property-listing <?php echo esc_attr($listing_view_class); ?>">
            <div class="row">

                <?php


                global $wp_query;




                $sort_args = array(
                    'posts_per_page' => $number_of_prop,
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'property_status',
                            'field'    => 'id',
                            'terms'    => '228',
                            'paged' => $paged,
                            'operator' => 'NOT IN'
                        ),
                    ),
                    'order' => 'DESC',
                    'post_status' => 'publish'
                );

                $sort_args = houzez_prop_sort($sort_args);


                $args = array_merge( $wp_query->query_vars, $sort_args );


                query_posts( $args );

                if ( have_posts() ) :
                    while ( have_posts() ) : the_post();

                        if($listing_view == 'listing-style-3') {
                            get_template_part('template-parts/property-for-listing-v3');

                        } else if($listing_view == 'listing-style-2' || $listing_view == 'listing-style-2-grid-view' || $listing_view == 'listing-style-2-grid-view-3-col') {
                            get_template_part('template-parts/property-for-listing', 'v2');

                        } else {
                            get_template_part('template-parts/property-for-listing');
                        }

                    endwhile;


                    wp_reset_postdata();
                else:
                    ?>
                    <h4><?php esc_html_e('Sorry No Result Found', 'houzez') ?></h4>
                    <?php
                endif;
                ?>

            </div>
        </div>
        <!--end property items-->





        <hr>

        <!--start Pagination-->
        <?php houzez_pagination( $wp_query->max_num_pages, $range = 2 ); ?>
        <!--start Pagination-->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.