Forums Forums Search & Filter Pro Additional loops on a results page possible?

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #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.

    Trevor
    #73623

    Are you using the Shortcode method for results? The sample results.php template we provide has the else condition that say no results found and this you can edit to do your own thing.

    Anonymous
    #74143

    I am using the post type archive setting for the results.

    Now knowing this is the results.php still relevant?

    Trevor
    #74508

    If you are using the Post Type archive method, then that uses theme templates, so you would need to modify the theme template to your needs.

    Anonymous
    #75265

    That is what I have done and what brought me to the point of reaching out. No matter what I have tried to do I cannot add an additional loop to the template. I have done this many other times on other sites I have built.

    Trevor
    #75296

    Have you always used the same theme/theme framework when you have done this before?

    Anonymous
    #75377

    Yes, it’s a straight forward archive page with the loop. I have been able to close the loop, reset the postdata, and run another custom loop.

    Trevor
    #75379

    OK. Well, when Ross gets in on Monday, I will ask him to take a look.

    Ross Moderator
    #75743

    Hi 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
    #77825

    I 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;

    ?>
    `

Viewing 10 posts - 1 through 10 (of 11 total)