Skip Navigation

[Resolved] How to detect when there is only one search result…

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 6 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2697989
Screenshot 2024-05-15 at 20.24.44.png

I have a search page (hidden link) built with Toolset with a filter search that shows some products. I have added the following code in order to list the results number:

[wpv-found-count] [wpml-string context='RESULTS']RESULTS[/wpml-string]

Is there a way to detect when there is only 1 result and consequently change the word RESULTS to RESULT ?

Thank you in advance!

#2698118

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Assuming that you are using Toolset Block - what if you try to add the conditional block and add the "Result" and "Results" word accordingly when there is one result display "Result" and when more than one display "Results".

Please check the following Doc:
- https://toolset.com/2021/08/5-advanced-uses-of-toolsets-conditional-block-in-wordpress/#display-a-submission-form

Where as you can see under the "How-To Steps" section - you should compare the condition to if number of items found by view equal to 1 you should display "Result". Add another conditional block and compare the condition to if number of items found by view greater than 1 then display "Results".

I hope the solution shared above will help you to resolve your issue.

#2698151

Hi Minesh,
thank you!

That was the way to go, thank you