Skip Navigation

[Resolved] How to filter a View by multiple post relationships

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client includes a post relationship filter in a View, but wants to include more than one.

Solution:
Multiple post relationship filters are currently not supported, but a request to enable this has been logged.

This support ticket is created 6 years, 8 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 8 replies, has 5 voices.

Last updated by shawnW-3 4 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#784699
download.png

Hi!

I wuold like to filter a view by post relationship setting multiple ids in the view shortcode but it works only with a single id, not multiples even if they are separated by a comma:

[wpv-view name="scuola-sedi" scuola="[wpv-post-id],[wpv-post-field name='_sc_corrispondente' output='raw']"]

Is there a way to solve it?

#786562

Nigel
Supporter

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

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

Hi Antonio

It's not possible to filter by multiple related posts.

So, on my test site I have events connected to artists, and I have a View to display the artists appearing at the event that I specify with an attribute 'wpvrelatedto'.

This works:


[wpv-view name="artists-appearing-at-events" wpvrelatedto="5"]

And this works:


[wpv-view name="artists-appearing-at-events" wpvrelatedto="20"]

But this doesn't work:


[wpv-view name="artists-appearing-at-events" wpvrelatedto="5,20"]

So it is not a question of how to correctly supply the list of post IDs, the problem is that filtering by multiple IDs is currently not supported.

It seems like a good idea, though.

I have just submitted a request to add this feature in a subsequent update.

#786667

Thank you Nigel!
I will wait for it.

#786882

Nigel
Supporter

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

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

OK, let me close here.

Keep an eye on the release notes when we publish Views updates to see if it has been added.

#1484207

Has there bern any progress in this? I am trying to do the same: filtering by multiple post relationships and I cannot see how to do it. Thx for an update on this issue.

#1484243

Nigel
Supporter

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

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

It isn't supported in the UI yet, but it is possible using code to modify the query.

Please open a new support thread and ask for me to respond, I'll keep an eye out for it.

#1779771

I am also interested to know if this functionality has been added as yet. I am building a view to display child posts with filters for two different parent post types... I have managed to add a filter for 1 parent type but the second returns the error:

"The ancestors argument does not end with a valid post that is related for the returned post types on this View."

#1779863

Nigel
Supporter

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

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

You can see an example of using the API to filter by two post parents at this link, but it refers to passing the parent IDs as shortcode attributes: hidden link

There is no feature to enable the same with front-end filters, I'm afraid @peter

#1998125

Hey Nigel. This would be an awesome feature and would save us from having to add redundant attribute filters.

Is this something that's being actively developed?

Also, I'd like to suggest adding to the feature request simple operators.

As stated:
Content Selection: Models
"Select posts in a Series Models relationship AND in a Lines Models relationship that are a related to the current post in the loop."
Shows ONLY the Models that in both a Series and a Line.

But Also:
Content Selection Models
"Select posts in a Series Models relationship NOT in a Lines Models relationship that are a related to the current post in the loop."
Shows the Models that are in a Series ONLY, excluding the Models that are in both a Series and a Line.

That logic might need some work, but I think you get the idea.