Nested Loopers with 2 Custom Post Types

Hey there. Maybe you can help me break out of my loo- aaah my circle if mistaken thinking :slight_smile:

I have CPT Events
Events reference another CPT: Venue

In Events, there is a meta key that contains the Post ID of the Venue, {{dc:post:meta key="_EventVenueID"}}
There is not a meta item in Venue that references the Events it is used in.

I tried to set up my loops as follows:
A Section contains the looper provider - Query Builder, Events, specific event selected to narrow it for testing.
This Section is also set as the consumer.
A Div inside this Section contains the looper provider - Query Builder, Venue, no other restrictions. The div is also set up as the consumer. This returns 3 results. (All three Venues currently created.) I am looking for 1 result, the Venue related to the Event specified by the parent Looper.

A text element in the nested Div shows that I am getting Venue meta data in the nested looper. Now the goal is to restrict it by the event it is being shown with.

I have tried to create a way to say “If Venue Post ID matches Event Meta _EventVenueID, return the Venue” through the meta function in the query builder and through Conditionals. I’ve combed through the documentation (which is missing some of the very nice new features of loopers) and the videos, but the nesting/referencing in examples is mostly parent/child, directly nested data, that kind of thing.

I’m just not thinking about this right and I’ve gone around and around with it. How can I better structure this?

Hey @glindacreative,

Thanks for reaching out!

You need to show a specific venue for your events right? I suspect what you are trying to achieve can relate to the ACF relationship.

A good example: Custom fields & ACF on a Single Layout: Loop a post type filtered by another post type

But if you are referring to something else, would you mind sharing more information? Providing screenshots or videos is a great help.

Thank you.

Thank you for that! I think that may have been the extra perspective I needed.

I didn’t quite end up following the same path as the other poster. What I wound up selecting was this option for the nested loop: post_type=tribe_venue&p={{dc:post:meta key="_EventVenueID"}} This works great! My next test involved trying with 2 venues on the same event, to see if my solution has any issues. Unfortunately it does!

Question - If there are two entries for _EventVenueID what’s the protocol for using that with a dc tag?

Or is that not supported? It’s not being stored as an array of IDs, it’s clearly two separate entries. the DC tag defaults to the first in the list. Is there a method for handling repeated keys like this?

I’d love to avoid using ACF to create an additional bridge between the two post types (the more moving parts, the more opportunities to break something!) but if the way the native event tool handles this ends up being incompatible then it’s nice to know ACF is there to help!

Hey @glindacreative,

The Event Venue ID should be saved as an object and returned as an array so that you can display the venues using another looper. Can you please provide us with your WP details so we can check the post meta and may be we can provide another solution? You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

Added secure note to previous post. As mentioned you have free reign with the data you see attached to the sandbox page I provided. Based on what you’ve said I think we’ll have to work around the native plugin behavior with ACF or a bit of custom code to push the stored venue ID data into an array format. A little weird that they wouldn’t store it as an array to begin with!

I’m guessing you already did something! {{dc:post:meta key="_EventVenueID" multiple=“true”}} Multiple wasn’t an option before!

Hey @glindacreative,

You will have to run a nested looper like this:

Looper Provider Query String (to display event items)
    Looper Consumer 
         Looper Provider Dynamic Content `{{dc:post:meta key="_EventVenueID" multiple=“true”}}` (to display the items in the array)
               Looper Consumer

Hope this helps.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.