Forums Forums Search & Filter Pro Count posts based on filters

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #41241

    Hi,

    is there a way to show counter of posts based on what is selected in filter? So if no selection it will show a number of all posts (ex. 45 results found), if I select something it will show a number of filtered posts (ex. 23 results found).

    Regards

    Trevor
    #41311

    Whilst I have asked Ross to take a look at this post, I just wish to make sure I have understood your question.

    This is something different to have the numbers next to each category and the pagination, yes? Something like a heading that says:

    23 results found based on your selections (if any)

    at the top of the results, maybe?

    Trevor
    #41313
    Ross Moderator
    #41391

    Hi Klox

    This is of course possible.

    Which display method are you using?

    With any query you can do:

    echo $query->found_posts

    Provided the name of the query is $query

    thanks

    Anonymous
    #41468

    Hi, thanks for pointing me in the right direction. At the end I did this $wp_query->post_count

    Trevor
    #41469

    Great 🙂 Can I close this thread and mark it as resolved?

    Anonymous
    #41614

    Acctually $wp_query->post_count takes into account “results per page” so I have to change this because if there are many pages with results and limit is set to 12 it will say “12 results found”.

    Ross Moderator
    #41616

    I think what you want is

    $wp_query->found_posts

    It is part of any WordPress query, and tells you total found, not including pagination.

    Thanks

    Anonymous
    #41619

    Resolved. Thanks.

Viewing 9 posts - 1 through 9 (of 9 total)