Problem: I have two post types in a one-to-many post relationship. Artists are the parents, and Paintings are the children. In the Artists post type, I have a checkbox custom field. I would like to create a View of Artist posts that only shows Artists with related Paintings. I would also like to include any Artist where the checkbox is checked.
Solution: To accomplish this without custom code, you need 3 Views:
- #1: View of Artists, filtered by checkbox field. Use the legacy Views editor and choose the output type "List with separators". Output the Artists IDs as a comma-separated list.
- #2: View of Artists, filtered by post ID using a shortcode attribute "ids". Design the output as you would like to see on the front-end of the site.
- #3: View of Paintings with no filters. Use the legacy Views editor and choose the output type "List with separators". In the loop, include the post ID of the parent Artist post.
Insert View #2 in your template or page using a shortcode. In the ids attribute, place View #1 and View #3.
Problem: I have two post types - Hosts and Structures - in a post relationship. Each User can be the author of one Host post, and can create multiple Structure posts using Forms. When the User submits a Form to create one of these Structure posts, I would like to automatically connect it to the User's Host post.
Solution: Use the cred_save_data API to trigger custom code when the Structure post is created. Use the toolset_connect_posts API to link the two posts programmatically.