Dear Sir/Madam,
I have a child post host and its parent post column, I create a View to filter the host belong to specific program using the wpvprchildof shortcode. When I create a page to embed the View, I don't know to get the parent post id, I read https://toolset.com/forums/topic/retrieving-the-parent-post-id-in-a-child-view/ and try to type $column in Post relationship field but not fine. How can I get the parent post id?
Best regards,
Kelvin.
Dear Kelvin,
Are you using Types plugin to setup the parent/child post type relationships?
If it is, for example the parent post type is using slug "program", then you can get the parent post ID with shortcode:
[wpv-post-id id="$program"]
More help:
Displaying Fields of Parent Pages
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
Dear Luo Yang,
I did try to enter $program in the Post Relationship field but it prompted numeric is required.
Best regards,
Kelvin.
I assume you are going to do this:
Create a new wordpress page, put the view into the page content, and display the child host posts of specific parent program post, for example the specific parent program post ID is 123, then you can put the Views shortcode into the page content as below:
[wpv-view name="your-view-slug" wpvprchildof="123"]
Dear Luo Yang,
I assign a Content Template for the custom post type "program", when I view the custom post, I assume to have the details of this program and its child post "chapter", should I create an View to list out the chapter post according to current program post, so the id is not manually insert into the shortcode, I don't know how to get current program id.
Best regards,
Kelvin.
You should use the filter:
Post where this View is shown,
See document:
Querying and Displaying Child Posts
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
Screenshot:
hidden link
Then you do not need to specific the parent "program" post ID.
I try to add $program in "In specific post" but it return error, I think Toolset may consider to allow user to add the parent post slug or there is a drop down menu for selection rather than only numeric input.
Kelvin
I tested it in my localhost, when you insert a Types shortcode with built-in UI, there is an option "The parent of this post, set by Types (parent/child relationship)", see screenshot: 202.JPG