Passer la navigation

[Résolu] How to detect when there is only one search result…

This support ticket is created Il y a 2 years. There's a good chance that you are reading advice that it now obsolete.

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 -

Fuseau horaire du supporter : Asia/Kolkata (GMT+05:30)

Ce sujet contient 1 reply, a 2 voix.

Dernière mise à jour par Minesh Il y a 2 years.

Assisté par: Minesh.

Auteur
Publications
#2697989
Screenshot 2024-05-15 at 20.24.44.png

I have a search page (lien caché) 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

Les langues: Anglais (English )

Fuseau horaire: 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