Skip Navigation

[Closed] How to pass variables to Views

This support ticket is created 8 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Beda 8 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#344944

I am trying to:
use the same Views passing a variable to it.

Im ending up having many Views. Is there a way to use just one (for all the similar content) and pass only the variables on the fields needed? Would be particularly useful.

For example -->
Content selection (here pass the CPT as a variable)
Query filter and loop code, etc. the same.

Calling the shortcode would need a variable as well in the parameters, in this case related to the CPT used.

#345033
Bildschirmfoto 2015-11-05 um 15.50.26.png

Thank you for contacting us here in the Support Forum

1. Use the same Views passing a variable to it.

For some Query Parameters this is possible:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

2. For example -->
Content selection (here pass the CPT as a variable)
Query filter and loop code, etc. the same.

As you see in the link above, that's only possible for:
Custom fields
Taxonomies
Author
Post IDs
Post relationships

3. You insert the View as this:
(example of shortcode attribute "available)

[wpv-view name="houses" available="1"]

It's also available in the Wizard, when you insert the View in a Post, you are asked to pass the argument.

Thank you for your patience.

#345256
Screen Shot 2015-11-06 at 11.50.26.png

Hi

I dont know how to add a Custom field filter. I see 3 on the list but its not clear where they come from and how I could add a new one. see the image.

I could pass the CPT from the url with a function as a custom field, I don't know if this is gonna help though.

Also, is there any future plan to pass custom post types as arguments?

thanks

#345576

1. Passing a Post type as ShortCode parameter is not in our plans, for different reasons:

- We have a section to choose as many Post Types you want in each View.
(Content Selection)
- It is a performance concern, querying all Post Types always, and only return what you determine in the ShortCode, means longer (and senseless) load times.

2. Those Custom Fields in your screenshot are either by other plugins or your (with Types) created ones.

You can create new Custom Fields and assign them to Post Types with Types Plugin:
https://toolset.com/documentation/user-guides/using-custom-fields/

They can then be chosen from the Views Query Filter > Custom Fields section.

Please let me know if you need further infos about this.

This are the DOC's to Views Parametric Searches and Query Options:
https://toolset.com/documentation/user-guides/front-page-filters/
https://toolset.com/documentation/user-guides/views/ > Learn more > Query filters (page's bottom)

Thank you for your patience.

The topic ‘[Closed] How to pass variables to Views’ is closed to new replies.