I have a system with nested relationships, and I am trying to show a form for adding grandchildren to a post within a view that is embedded on the content template for the Grandparent post.
Like my other ticket the relationship field is not populating the parent from the view. Maybe I need to pass the value as an attribute, or to put the form on a separate template or page? Really not sure on this one...
This is probably also best addressed by letting you guys have access to the site.
Please enable private reply fields.
Hello,
I assume we are talking about this case:
1) Three post types:
- Grandparent
- Parent
- Child
2) Two post type relationships
- One-to-many relationship between "Grandparent" and "Parent"
- One-to-many relationship between "Parent" and "Child"
3) In the single "Grandparent" post, you are going to create new "Child" post
If it is, you can try these:
in the single "Grandparent" post, display a post view:
- Query "Parent" posts
- Filter by relationship between "Grandparent" and "Parent"
https://toolset.com/course-lesson/displaying-related-posts/
- In view's loop, display the form link for creating new "Child" post
See our document:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/
I believe you have the overall structure correct.
The issue I have is that I need to grandparent to be displayed after submitting the child post.
One thought I had is with a site had built several years ago that is now gone unfortunately, but someone on here had helped me to build a system where child post forms would popup in a separate window, but I can't find the ticket where they showed me how to do that. There is a related ticket about refreshing the parent window after a child was submitted in another window here:
https://toolset.com/forums/topic/refresh-parent-page-after-adding-child-post-in-new-window/
I think something like this might work for my current project if you can help me get that working again.
Alternatively, if I could have a button/link that takes me from the current grandparent post to the children view and lets me loop through them one at a time and then return back to the grandparent post, that would be even better...
For the new question:
if I could have a button/link that takes me from the current grandparent post to the children view and lets me loop through them one at a time and then return back to the grandparent post, that would be even better...
How do you setup the option "After visitors submit this form" of post form for creating new child post?
If it is value "Display the post", and redirect to the child post it self, in the single child post, you can display grandparent post information by these:
1) Create a content template, for example "parent-post-info", in the content display the grand parent post link
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-link
2) In the single child post, display above content template shortcode with item attribute:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body