Skip Navigation

[Resolved] Multiple ID filter of view

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

Problem:

I have a shortcode of this type:

echo do_shortcode ('[wpv-view name = "10-next-matches" view_display = "layout" wpvrelatedto = "769,770"]');

But it doesn't work. This does not show me the matches of the chosen team IDs.

Solution:

You can try these:

1) Edit the post view "10-next-matches", in section "Query Filter", setup the filter as below:

Select posts in a YOUR-POST-REFERENCE-FILED-NAME relationship that are related to the Post with ID set by the URL parameter wpv-relationship-filter

2) Edit your PHP codes as below:

https://toolset.com/forums/topic/multiple-id-filter-of-view/#post-1732667

Relevant Documentation:

This support ticket is created 3 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
- 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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by christopheV-2 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1727675

Hello,

Is it possible to put multiple IDs in the search filter of a view for a relational field?

I have the impression that we can put only one ID.

Thank you.

#1727895
related-post.JPG

Hello,

The custom "Post Reference" field is based on one-to-many relationship, within Views, you can pass multiple parent post ID to views, and get related child posts.

For example, edit your post view, in section "Query Filter", setup the filter as below:
Select posts in a YOUR-POST-REFERENCE-FILED-NAME relationship that are related to the Post with ID set by the URL parameter wpv-relationship-filter.
eg. hidden link

See screenshot related-post.JPG

Then in front-end, you can pass multiple parent post IDs to view, like this:
eg. hidden link

It will be able to get all related child posts by parent post ID 123 and 456

#1732349

Hello,

I don't quite understand.
I have a shortcode of this type:
echo do_shortcode ('[wpv-view name = "10-next-matches" view_display = "layout" wpvrelatedto = "769,770"]');

But it doesn't work. This does not show me the matches of the chosen team IDs.

Thank you

#1732667

Thanks for the details, you are using shortcode attribute filter, it supports only one parent post ID, does not support multiple IDs as parameter.

You can try these:
1) Edit the post view "10-next-matches", in section "Query Filter", setup the filter as below:
Select posts in a YOUR-POST-REFERENCE-FILED-NAME relationship that are related to the Post with ID set by the URL parameter wpv-relationship-filter.
eg. hidden link
See the screenshot:
https://toolset.com/wp-content/uploads/2020/08/1727895-related_post.jpg

2) Edit your PHP codes as below:

	$_GET['wpv-relationship-filter'] = array(769,770);
	echo do_shortcode ('[wpv-view name = "10-next-matches" view_display = "layout"]');
#1733555

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.