Skip Navigation

[Resolved] Filter options in wpv-control-post-relationship

This support ticket is created 4 years, 7 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)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Shane 4 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#1962547
Screenshot 2021-02-22 at 1.31.41 PM.png

I have the following page

hidden link

That is showing a list of publication types, which have a many 2 many relationship with another type called person.

The combo shows all the available people as selectable options through a "post relationship or repeatable field group owner" (see attached.

This filter is controlled through the following code

[wpv-control-post-relationship ancestors="person@publication-person.child" url_param="wpv-relationship-filter"]
[wpv-control-post-ancestor type="select" ancestor_type="person@publication-person.child"]
[/wpv-control-post-relationship]

What I would like to do is to limit the available option in the

[wpv-control-post-ancestor type="select" ancestor_type="person@publication-person.child"]

based on a property of the 'person' type.

Some 'people' are archived or not part of our team anymore, or may be external.

Is there any way to limit the options on that select box?

I am comfortable writing some code to replace that 'wpv-control-post-ancestor' shortcode.

Thanks

#1962909

Shane
Supporter

Languages: English (English )

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

Hi Gregoris,

Thank you for getting in touch.

While i'm not aware of any way to do this using a PHP hook, we can hide the specific persons using Javascript if you know the persons who should be excluded from the list.

Add the following to the JS editor of your view.

jQuery(document).ready(function() { 
jQuery('#wpv_control_select_wpv-relationship-filter').find("option:contains('Alexandros Bousdekis')").hide(); 

}); 

All that is needed is to add another line of

jQuery('#wpv_control_select_wpv-relationship-filter').find("option:contains('Alexandros Bousdekis')").hide(); 

Then change the name that is in the contains function. In my case I did it as an example with "Alexandros Bousdekis".

Please let me know if this helps.
Thanks,
Shane