Update "found posts"

Forums › Forums › Search & Filter Pro › Update "found posts"

Viewing 10 posts – 1 through 10 (of 11 total)
  • Anonymous
    #160020

    Hi,

    I would like to put this function outside of results.php to place it in a particular place:
    Found <?php echo $query->found_posts; ?> Results

    But that does not work (normal).
    It works if I slightly chance the function:
    Found <?php echo $wp_query->found_posts; ?> Results

    But it does not update when searching (Ajax).

    Is there a way to make it work?

    Thanks in advance.

    Trevor
    #160149

    Ajax only updates part of your page. Anything inside the container that it updates will change, but you may have inserted the count outside that container. In the shortcode method, what is inside results.php gets refreshed, what is outside does not.

    Anonymous
    #160161

    Ok, that’s what I told myself.
    But it’s not possible to recover the value with a callback?

    Trevor
    #160163

    You COULD use this function, by adding your own javascript to alter other parts of the page:

    <script>(function ( $ ) {
      "use strict";
      $(document).on("sf:ajaxfinish", ".searchandfilter", function(){
        console.log("ajax complete");
    // load your code here
      });
    }(jQuery));</script>

    This will trigger every time our Ajax call is run.

    Anonymous
    #160204

    Your code works, thanks!
    And do you know where is the data “number of results”?

    $(document).on("sf:ajaxfinish", ".searchandfilter", function(data){
    	console.log(data);
    });
    Trevor
    #160206

    Isn’t that what you have?

    Anonymous
    #160210

    I have an object with infinite information.

    Trevor
    #160212

    I do not understand?

    Anonymous
    #160214

    Here is what I have in my console.

    Trevor
    #160216
    This reply has been marked as private.
Viewing 10 posts – 1 through 10 (of 11 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.