Skip Navigation

[Resolved] Display post inside another post filtered by field value

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

Problem:
I created a post type called "Stores" that displays store info and a Google map for each store. I created a second post type called "Upcoming Events" that shows event information and date of each event. I would like to display Upcoming Events for each store based on the value of a field (Store Number) from the Store post type. The store number is part of the information entered for each store, it is not the post ID. I would like to be able to create an Upcoming Event and enter a comma separated list of Store Numbers in order to display the event on one or more store pages.

Solution:
In your case, one "Upcoming Event" post can connect to multiple "Stores" posts, and one "Stores" post can connect to multiple "Upcoming Event" posts, that is many-to-many relationship,

I suggest you follow our document to setup many-to-many relationship between post type "Upcoming Event" and "Stores", within many-to-many relationship, it is not required to re-entering the same Upcoming Event info for each store location.

Relevant Documentation:
Creating and Displaying Many-to-Many Post Relationships
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

This support ticket is created 6 years, 5 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)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#587325

I have a site that displays the company's retail locations. I created a post type called "Stores" that displays store info and a Google map for each store. I created a second post type called "Upcoming Events" that shows event information and date of each event. I would like to display Upcoming Events for each store based on the value of a field (Store Number) from the Store post type. The store number is part of the information entered for each store, it is not the post ID. I would like to be able to create an Upcoming Event and enter a comma separated list of Store Numbers in order to display the event on one or more store pages.

I don't think making a child post of the Stores post type is a good solution because I want to be able to create an Upcoming Event one time and display it on multiple Store pages. As far as I know, making a child post would require re-entering the same Upcoming Event info for each store location (Unless I'm wrong?)

I've tried doing this with conditionals comparing the "Store Number" field from the Stores post with the value of the "Which Stores" field from the Upcoming Events post, but I'm having no luck.

Here's pseudocode to further explain what I'm trying to do:

If (one of the values from the "Which Store" field in Upcoming Events) = (The value of the field "Store Number" on this page){
Display content
}

#587404

Dear rusty,

In your case, one "Upcoming Event" post can connect to multiple "Stores" posts, and one "Stores" post can connect to multiple "Upcoming Event" posts, that is many-to-many relationship,

I suggest you follow our document to setup many-to-many relationship between post type "Upcoming Event" and "Stores", within many-to-many relationship, it is not required to re-entering the same Upcoming Event info for each store location.

See our document:
Creating and Displaying Many-to-Many Post Relationships
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

And in each single "Stores" post, you will be able to display the related "Upcoming Event" posts with Views plugin, see above document, section:
Displaying Many-to-Many Relationships Using Views

#587788

This is exactly what I needed! Works perfectly!
I knew I couldn't be the first person to need this and I also knew Toolset would deliver.
Thanks Luo!

#587863

You are welcome.

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