Problem: I have two custom post types in a M2M relationship, Persons (parent) and Project (child). I have added a custom field to the relationship, and I would like to sort a View of related Project posts using the custom field value. I would like to place that View of related Projects inside another View of Persons, to create a list of all Persons and their related Projects.
Solution:
- Make sure the intermediary post type is set to be visible. Go to Toolset > Post Types and edit the intermediary post type. Set the status to "Publish" and check the Options panel to be sure publicly_queryable, show_ui and show_in_menu are checked.
- Create a View of Projects. In the Loop Output area, insert a shortcode to display the post title.
- Create a View of Persons Projects (the intermediary post type). Set up a post relationship filter. Choose the correct M2M relationship and "related to the current post in the loop". Sort by the custom field value as needed.
- In the Loop Output area of the View insert a shortcode to display the custom field role information.
- Just after the role information, insert another post title shortcode. This time use the Post Selection tab in the popup to select the related Person post as the source of the title. This will display the related Person's name.
- Now insert the View of Persons Projects inside the Loop of the View of Projects, and insert the View of Projects somewhere to test it out on your site.
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 3 replies, has 2 voices.
Last updated by 6 years, 5 months ago.
Assisted by: Christian Cox.