Forums Forums Search & Filter Pro Update "found posts"

  • This topic has 10 replies, 2 voices, and was last updated 7 years ago by Anonymous.
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)