What I'm trying to do is create two queries for properties. One will receive regular results based on a regular query. The second request will receive properties that are closely related to the first request. I can run both queries and retrieve all the results using the posts_per_page function, unlimited and without pagination. The problem with adding pagination is that both loops start and display messages on each page.
The page will have 3 from the first cycle, and then 3 from the second cycle.
I tried to combine the two queries into one and show them, but the same results. 3 and 3.
I think I need to add something to make sure that the second loop gets the output after the first. Any thoughts?
Here are my loops (I excluded arguments due to length)
<?php $queryOne = new WP_Query($args); $queryTwo = new WP_Query($args2); $results = new WP_Query(); $results->posts = array_merge($queryOne->posts, $queryTwo->posts); ?> <?php foreach($results->posts as $post) : ?> <?php setup_postdata( $post ); ?> <?php get_template_part( 'property-listing' ); ?> <?php endforeach; ?>
source share