Skip Navigation

[Resolved] Showing a view from one post type in a many-to-many relationship on another type

This support ticket is created 3 years, 10 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 2 replies, has 2 voices.

Last updated by michaelS-53 3 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1659517

We have two post types, one called "Games" and the other called "Posts", set up in a Many-to-Many relationship. Under "Games" we have a repeatable field called "Affiliates" which we want to display on other post-types like "Posts". I can call the view where the fields are displayed on "Games" via PHP no problem (for various reasons we are embedding this view in PHP), but I'm not sure how to target it so "Posts" pulls in the same data.

The code I'm using on the "Games" type looks like this:

<!-- Affiliates -->
<?php $affiliates = get_the_terms( $post->ID, 'review-aff-links', true);
if (!empty($affiliates)) {
echo do_shortcode("[wpv-view name='affiliate-links-games']");
} ?>
<!-- /Affiliates -->

Is there something we can add here to make it work so "Posts" pulls the same affiliate data entered in "Games"? Thanks.

#1660375

Shane
Supporter

Languages: English (English )

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

Hi Michael,

Thank you for getting in touch.

Given that your Repeatable fields are on the Games Post type you are going to have to do a nested view type setup.

You're going to have to create a view that lists out Games and a view that lists out the Affiliates.

First when you create the Affiliate view, you will need to add a query filter to it for Post Relationship and set it to get the value from the Current post in loop.

Secondly you will need to Create your Games view and then add a Query filter for Post Relationship and set this to get the value from the Current Page.

Then you're going to add your Affiliates view inside your Games view within the wpv-loop tags .

Finally you just need to add your Games view to the Post Template.

This will allow you to list out the relevant Affiliate that is tied to that post through its Games relationship.

Please let me know if this helps.

Thanks,
Shane

#1660827

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.