Skip Navigation

[Resolved] Search Filters shows all posts as default before selecting search criteria

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 2 replies, has 2 voices.

Last updated by Munro 7 years ago.

Assisted by: Nigel.

Author
Posts
#594557
Screen Shot 2017-11-29 at 8.13.12 PM.png
Screen Shot 2017-11-29 at 8.37.13 PM.png
Screen Shot 2017-11-29 at 7.59.11 PM.png

Hello,

I have created a parametric search with categories but don't want anything showing by default. Is this possible?

I am trying to recreate this website hidden link

Which is going well, I just need to hide the listings by default before a category or item is selected and can't figure it out..

my site is here hidden link

(Eventually I would like a A-Z listing as well. but can follow the guides in the forums)

Thanks very much for any help you can give,

Todd

#594611

Nigel
Supporter

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

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

Hi Todd

You can do this using the Views API and the wpv_filter_query or wpv_filter_query_post_process filters (https://toolset.com/documentation/programmer-reference/views-filters/) but the simplest way is to use a conditional shortcode in your Loop Output editor to show or hide the loop depending on whether there is a search term for your taxonomy in the request.

Here is a simplified example to show you the principle:

[wpv-layout-start]
	[wpv-items-found]
	[wpv-conditional if="( '[wpv-search-term param='wpv-category']' ne '' ) AND ( '[wpv-search-term param='wpv-category']' ne '0' )"]
	<!-- 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]

We are testing to see whether we the wpv_category URL parameter is present in the query (and if it is we know something has been selected).

#594726

Thanks Nigel it worked!

I did try conditionals at one time but I was using param='category' instead of 'wpv-category' which didn't work.

Thanks for directing me back to the right way of doing it.

Todd