Skip Navigation

[Resolved] Require a value to be entered in the search in order to show results.

This support ticket is created 3 years, 10 months ago. 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 -

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

This topic contains 4 replies, has 2 voices.

Last updated by Dee_DeeA2948 3 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1884649

Tell us what you are trying to do?
Currently, when I just click "search", it shows all of the posts. If a website visitor clicks "search" without entering any characters, I don't want it to show all posts. I found this thread here: https://toolset.com/forums/topic/how-to-force-blank-search-to-return-no-results/

When I entered the recommended text (from this thread) into my custom php plugin-- it broke the site. No biggie. I was easily able to undo this... I just wasn't able to get it to work 🙁

What is the link to your site? I'm referring to my prepnavigator website. My search is based on the post title. This is the ONLY field used for the search. Let me know if you need more information.

Thank you for your help.

#1885097

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know, are you using Toolset Blocks or Toolset Views?

#1885557

Hi. I am using Toolset Views 🙂

#1885819

Minesh
Supporter

Languages: English (English )

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

Thanks for confirmation that you are using classic views.

So, the solution shared by Waqar with the following link should work for you. Have you try to add it within your view's loop editor?
=> https://toolset.com/forums/topic/how-to-force-blank-search-to-return-no-results/#post-1634461

if you do not know how to set that up, I have another workaround as well using view's hook wpv_filter_query.

Can you please share problem URL where you added your view as well as access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1886129

I didn't realize that I needed to insert this within the view's loop editor. I was adding it in the wrong place. Thank you for clearly explaining this in your message because it solved my problem!