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
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).
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