Skip Navigation

[Resolved] How to prevent custom search view to showw all posts initially

This support ticket is created 7 years 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
- 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)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 7 years ago.

Assisted by: Nigel.

Author
Posts
#594766

Ive made custom search view, but it shows all the posts before I enteren any value as the search parameter.

I would like to have just empty page, and any posts (or "Not found message") appears only AFTER the value entered into the search field ans search button pressed.
Is it possible?
Thank you

#594778

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

If you are just using a standard text search with the wpv_post_search parameter then you can conditionally display the View loop output (the results) only if a search term has been entered.

Here is a simple example that you can adapt to your needs:

[wpv-layout-start]
	[wpv-items-found]
[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' ne '' )"]
	<!-- wpv-loop-start -->
		<wpv-loop>
          <h3>[wpv-post-link]</h3>
		</wpv-loop>
	<!-- wpv-loop-end -->
[/wpv-conditional]
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

If you have multiple filters then you will need additional conditional tests, and it may be more efficient to use the Views API and the wpv_filter_query or wpv_filter_query_post_process filters (https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query)

#594942

Hello

sorry but it is not working - it shows no result at all , doesnt matter if I enter some search value or not
I am using the custom search setting in view
and try to filter post by custom field
set "AJAX results update when visitors click on the search button" option
looks like
[wpv-search-term param='wpv_post_search']
is always empty, besides what I entered in search field

#594998

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Can you show me the contents of your Filter Editor?

It looks like you are using a different URL parameter for the search, but I should be able to see from your Filter Editor.

You can paste in the contents, wrapping them in code tags for formatting.

Thanks