Forums › Forums › Search & Filter Pro › Additional loops on a results page possible?
- This topic has 10 replies, 3 voices, and was last updated 7 years, 10 months ago by Ross.
-
Anonymous(Private) November 30, 2016 at 8:41 pm #73381
Site – https://www.potatogoodness.com/recipes
For queries that provide no results I am wanting to list out popular recipes to encourage click through.
On all archive pages, that are not a results page based on this plugin, I can run a new query and output posts as well as the original archive/taxonomy results, but on search pages I cannot.
I assume this is due to the way that this plugin takes over the query. Is there a way for me to reset that somehow so I can run an additional loop? I have tried using wp_reset_postdata() at the end of my normal loop, but again I do’t think your plugin uses that on it’s results page.
Any help here would be appreciated.
Ross Moderator(Private) December 12, 2016 at 4:16 pm #75743Hi Richard,
How are you defining your extra queries in the template?
Basically, S&F doesn’t do anything too unusual when using the post type archive display method…
All we do is modify the global query, using the WP filter
pre_get_posts
.. so the way you are using wp_post_reset should not change just because you are using S&F.As a test, can you disable S&F, and figure out if your additional queries now work?
Let me know how you get on.
Thanks
Anonymous(Private) December 20, 2016 at 4:10 pm #77825I am running this query between the else and endif of the loop:
`
<?php$args = array(
‘post_type’ => ‘recipe’,
‘posts_per_page’ => 10
);$the_query = new WP_Query($args);
if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();
get_template_part(‘partials/recipe-grid-item’);
endwhile; endif;
?>
`
-
AuthorPosts