Skip Navigation

[Resolved] When URL parameter is blank or missing, Views returns all possible results

This support ticket is created 6 years, 5 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Shane 6 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#576941

This page includes multiple views that are only supposed to return when their State custom field matches the URL parameter state= -- but when I just load the page as is, it returns every possible content item. What I want is for it to return nothing when there's no URL parameter -- how can I do this?

hidden link

vs.

hidden link

#576964

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

Thank you for contacting our support forum.

There is only one way I can think of resolving this is to use our [wpv-conditional] shortcode to evaluate the url parameter to check if its empty.

We will need to use a combination of our shortcodes to achieve this.

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

And
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term

So how we will do it is like this.

<wpv-loop>
[wpv-conditional if="( '[wpv-search-term param="state"]' ne ' ' )"]

view contents here.
[/wpv-conditional]
</wpv-loop>

This will allow you to not display anything if there wasn't a state specified.

Please let me know if this helps.
Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.