Skip Navigation

[Resolved] Using wpv-view shortcode with conditionnal output parameters

This support ticket is created 3 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.

This topic contains 5 replies, has 2 voices.

Last updated by jean-francoisB 3 years, 5 months ago.

Author
Posts
#1827629
printscreen2.png
printscreen3.png
printscreen1.png

Hi,

I created a view that only show the title of post. The slug of this view is liste-de-partenaires.

On a page, I want to use wpv-view shortcode to show this view BUT i want to filter the results.

For example, I want to get the list of all post title for post having a custum field checkbox element checked.

This is what I have tried :

[wpv-view name="liste-de-partenaires" field="services-pour-groupes" option="0" state="checked"]

So the logic behing this is : Give me the list of all posts having the first option checked for the custom field services-pour-groupes. But the wpv-view is still showing all results instead of filtering the results with the parameter that I have specified.

What should I change to the wpv-view shortcode to get the results that I want?

printscreen3: In the result, we should only see Le Repère Vibratoire with the actual filter.

Thank you!

#1827909

When I use my search page to query all post where "atelier" is checked for the custom field "services-pour-groupes", I'm getting this in my URL : ?wpv-wpcf-services-pour-groupes[]=Ateliers+%2F+Formations

How can I put this in my wpv-view shortcode so the view only show posts where services-pour-groupes has "ateliers" checked?

Hopefully I'm clear in my request.

Thank you!

#1827929

I also try this : [wpv-view name="liste-de-partenaires" services-pour-groupes="ateliers"]

Where : liste-de-partenaire is the view
Where : services-pour-groupes is the custom field
Where : ateliers is one of the checkbox choices value

Result : The filtering doesn't work. All posts are showed instead of showing only those with "ateliers" checked from the services-pour-groupes custom field.

#1828697

Nigel
Supporter

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

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

First, please read the following to familiarise yourself with filtering, and passing values via shortcode attributes to the filters:

https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/
https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/

There is a complication with filtering by checkboxes custom fields because of the way they are stored.

It will only work if in the settings for the checkboxes custom field the options save different values to the database (rather than just each option saving '1' when checked, for example). Those values are the values that need to match in your query filter.

#1830239
Capture d’écran, le 2020-10-30 à 18.55.57.png

Hi,

Thanks for your answer! So actually, I didn't know that I had to setup a filter in the admin section (see attached) while using only a shortcode. I thought that by giving the name of the custom field would do the job. So I have to add something like 20 filters to cover all my custom fields that I have and that should do the trick. Just a little bit of work but I won't complain if it's working 🙂

Thank you for your help!

#1830265

My issue is resolved now. Thank you!

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