Skip Navigation

[Resolved] Select 2 CPT to display in a view in template for other CPT

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

Problem: I have two custom post types. On the template for CPT A, I would like to display two posts from CPT B in a View. In the post editor for CPT A, I would like to choose which two posts should be displayed in the View.

Solution: Use a many-to-many relationship between CPT A and CPT B to select which posts from CPT B should be displayed in each post of CPT A. Use a View of CPT B with a post relationship filter in the template for CPT A to display the selected posts.

Relevant Documentation:
https://toolset.com/glossary/post-relationships/
https://toolset.com/glossary/view/
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Deniz 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1729161

Hi,

I have a CPT page (CPT 1) with a view, this view displays two random results of another CPT (CPT 2).
It's works fine, but I need to be able to select in the backend which pages should be displayed.
So a double search in the backend on every CPT 1 .
Thanks

Regards

#1729721

Hi, I'm not sure I understand what you mean by a double search in the backend, but it sounds like you need the ability to connect two posts from CPT 2 with each post in CPT 1. You could do that with a many-to-many post relationship between CPT 1 and CPT 2. In the post editor for CPT 1, you will have the ability to select your posts from CPT 2. Then in the template for CPT 1, you can display a View of CPT 2 filtered by post relationship, such that the CPT 2 posts are related to the post where the View is displayed. That will display any CPT 2 posts you relate to each CPT 1 in the template for CPT 1. You would also be able to display CPT 1 in the template for CPT 2 if you'd like, but of course that's optional.

Will this solve the problem, or did I misunderstand what you want to accomplish?

#1730327

Hi Christian,

thanks for the reply, yes I think it's the solution.
Do you have any documentation for this?

Regards
Fabien

#1731427

Yes, I have these three relevant links for you to review:
https://toolset.com/glossary/post-relationships/
https://toolset.com/glossary/view/
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

Let me know if you have additional questions about post relationships and lists of related posts.

#1732927

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.