Skip Navigation

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

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

This topic contains 3 replies, has 2 voices.

Last updated by tony 3 years, 11 months ago.

Assisted by: 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



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)


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.




Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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!

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