Home › Toolset Professional Support › [Resolved] How to display message if View Limit is reached
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Tagged: Views, Views plugin
This topic contains 2 replies, has 2 voices.
Last updated by larryD-2 4 years, 10 months ago.
Assisted by: Nigel.
Tell us what you are trying to do?
If a View has a Limit set (e.g. "6"), how can I display a message to the user similar to "Due to the limit on this view, you are only seeing 6 items of 25 found." Ideally, this message would only be displayed if the limit is exceeded.
Is there any documentation that you are following?
Yes. https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-items-count and https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-found-count
Is there a similar example that we can see?
If I use code such as this for a search that exceeds the limit:
<div>Showing [wpv-items-count] items of [wpv-found-count] found.</div>
I get a message: "Showing 6 items of 6 found." I'd like to (conditionally) display "Showing 6 items of 25 found."
What is the link to your site?
hidden link
You would need credentials to see this page. Please let me know how to securely get you credentials, if desired.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Larry
The problem here is that when you set the limit option you are creating a database query that says "return up to 6 matching posts".
The wpv-found-count shortcode then operates on the results of that query, which can only ever have up to 6 posts.
You have two options.
One is to create a second View, with the same settings as the first View, but omitting the limit. The output of that View is just the wpv-found-count, nothing else, and you would likely want to choose the option to disable the wrapper div to keep the output simple.
Then insert that View in your first View where you had previously use the wpv-found-count shortcode.
An alternative is to remove the limit, but only output content for the first 6 results.
You could use the wpv-loop-index shortcode (https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-loop-index) with a conditional shortcode that wraps the output (so only outputs anything if the index is <= 6), or you could achieve something similar with the wpv-item shortcode (https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-item) where you output the same thing for wpv-item index=1, wpv-item index=2 etc. up to 6, and then nothing for wpv-item index=other.
Thanks for the clear reply with well-thought-out options. I wish this were a little easier, but I understand what needs to be done.
My issue is resolved for now. Thank you!