Is it possible to insert the total number of results found within a view using [wpv-found-count] without actually having to insert that View as well?
At the moment I have a View and I can use [wpv-found-count] within that View to output the total number of results found. I want to be able to use this data somewhere else without having to actually display any of the results.
Is this possible?
Hi Ben,
Thanks for asking! I'd be happy to help.
The value of shortcode [wpv-found-count] depends on the view's loop, therefore, I'm afraid, it can not be used without the view itself.
You can create a duplicate of your actual view and that new view, add "[wpv-found-count]" after the "<!-- wpv-loop-start -->" line. Next, you can remove everything from inside the tags "<wpv-loop></wpv-loop>".
This way, this new view will output only the number of results and not the complete markup from the actual view.
I hope this helps.
regards,
Waqar
Thanks for the reply Waqar!
Would this work if I inserted the original View into a new View and used [wpv-found-count] with your instructions on the new View?
Hi Ben,
Thanks for writing back.
Yes, you can nest the original view into the new one, but since the "[wpv-found-count]" value would be the same for both views, I can't think of a scenario, where they both will be needed to be used together.
Note: in case you need to show the count of view's results, outside its loop, you can also use some custom script, to show it at your desired place, using only a single view, as suggested in this reply:
https://toolset.com/forums/topic/how-to-display-the-total-amount-of-posts-in-search-results-parent-layout/#post-1130495
regards,
Waqar
Thank you for all your help with this Waqar, as well as that very useful information to!