Skip Navigation

[Resolved] How can I get parent post id

This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 7 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#402537
Screen Shot 2016-05-29 at 11.51.12 PM.png

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.

#402653

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/

#402691

Dear Luo Yang,

I did try to enter $program in the Post Relationship field but it prompted numeric is required.

Best regards,

Kelvin.

#402733

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"]

#402762

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.

#402948

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.

#404324
Screen Shot 2016-06-04 at 2.14.24 PM.png

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

#404564
202.JPG

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

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.