count of total posts?

Forums › Forums › Search & Filter Pro › count of total posts?

Viewing 2 posts – 1 through 2 (of 2 total)
  • Anonymous
    #238223

    Hi,
    Our search listing has at the top “Found 5 Events” but what we really want is “Found 5 of 21 Events” where 21 is the number of Events shown when no filters are set. The code we use is:
    Found <?php echo esc_html( $query->found_posts ); ?> Events
    Is there an easy way for us to find the total Events on the list when no filters are set? The only way I can think of doing this is by writing a select count(*)... call directly to the DB that mimics the same query.

    Thanks,
    Chris

    Trevor
    #238252

    I don’t think that there isn’t an easy way to do this. You would have to create a second wp_query() for the page solely to calculate this, and your database and server would take a resource hit as a consequence, I suspect.

    I would be looking for code snippets on the WordPress section of the StackExchange site.

Viewing 2 posts – 1 through 2 (of 2 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.