Skip Navigation

[Résolu] Views -Select posts in a relationship that are related to any of multiple values

This support ticket is created Il y a 4 années et 1 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par tony Il y a 4 années et 1 mois.

Assisté par: Waqar.


Tell us what you are trying to do?

I have people related to membership statuses.

I want to list all people that are related to any of selected membership statuses but can only select one value.


Fred > Adult
Jim > Adult
Connie > Adult Senior
Annie > Under 18
Billy > Lapsed Member

I want to select all people where membership has not expired (no problem I can do this)
who are an "Adult" or "Adult Senior" or "Under 18"

The selection box only allows me to select a single membership status value.

Please can you assist?


Select items in the membership statuses people relationship
as related items of...

Specific: [Membership Statuses v] Adult v

I am using Views - very wary about updating versions since recent changes



Thank you for contacting us and I'd be happy to assist.

Your observation is correct and when filtering posts by relationship, only a single item can be selected.

To suggest some workaround, I'll need to see exactly how this relationship and view are set up in the admin area.

Can you please share temporary admin login details along with the link to a page with this view?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.



Hi Tony,

Thank you for sharing these details.

To filter results at the query level, based on the relationship with multiple terms, you can use "wpv_filter_query" filter ( ref: ) and "toolset_get_related_posts" function ( ref: ).

For example, suppose that your View ID is 12345 and the target status posts IDs are 4, 6 & 8 and the involved relationship slug is "membership-status-person", then the function will look like this:

add_filter( 'wpv_filter_query', 'filter_specific_status_fn', 1000 , 3 );
function filter_specific_status_fn( $query_args, $view_settings ) {

	if ( !is_admin() && ( isset($view_settings['view_id']) && $view_settings['view_id'] == 12345) ) {
		// IDs of the required statuses
		$req_statuses = array(4, 6, 8);

		foreach ( $req_statuses as $post_array ) {
			// get parent post in a relationship
			$query_by_element = $post_array; // ID of post to get relationship from
			$relationship = 'membership-status-person'; // relationship slug
			$query_by_role_name = 'parent'; // $query_by_element is a parent in this relation 
			$limit = 999999; // defaults
			$offset = 0; // defaults
			$args = array(); //nothing needed
			$return = 'post_id'; // We want Post ID
			$role_name_to_return = 'child'; // We want child.

			$get_results = toolset_get_related_posts(
			foreach ($get_results as $get_result ) {
				$query_args['post__in'][] = $get_result;

	return $query_args;

Feel free to adjust the snippet as per your website and it can be included through either Toolset's custom code feature ( ref: ) or through active theme's "functions.php" file.

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:



My issue is resolved now. Thank you!

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance