I'm having a hard time figuring out relationships and I can't seem to find the right help on your site.
I'm hoping you can point me to some resources.
I am building a database tool with three custom post types, each with their own set of custom fields:
1) The main (maybe parent?) post type, which contains user information (name, age, address, etc.)
2) A sub-post type that will contain a list of service records for each user (service type, date)
3) Another sub-post type that contains a list of people related to the user in the main post type
When a record (post) from the main post type is displayed, I want it to display the two sub-post types associated with it. I can't figure out how to do this.
Based on your description I suspect that you want a setup like this below.
- Parent Post A
--Child Post A
-----Grand Child Post A
All of this information being displayed on Parent Post A page. If so then this is going to require at least 1 nested view. The First step is that you need to create the grand child view.
On this grand child view you will add a query for the Post Relationship. If you're not seeing the query filter section you must scroll to the top of your page and on the top right hand corner you will see Screen Options click this and enable the Query Filters. Now scroll to the Query Filter section and Add a Filter for the Post Relationship, then select the relationship from the dropdown and set the filter to " The current post in the loop". See Screenshot
Now that we have the Grand Child view created, you're going to repeat the above steps to create the Child view, however instead of setting the Child view's Post Relationship filter to " The current post in the loop" you will set it to "The post where this View is shown".
The next step is to nest the grand child view into the Child view, this can be done by using the Fields and Views button in the Loop Editor section of your view and select your child view and add it. Ensure that the child view's shortcode is added within the <wpv-loop> tags.
Finally you will add the child view itself to the template of your Parent post. Once this is done correctly you should see the correct relational information being displayed according to the Parent view.
Please let me know if this helps or if you're having trouble with any of these steps.
Thanks,
Shane
The topic ‘[Closed] Instructions for using relationships’ is closed to new replies.