Skip Navigation

[Resolved] How to access the parent ID

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to access the parent ID from child post

Solution:
to access the parent ID when you have created post type relationship with Types plugin version 3.x.x - you can use the following shortcode:

[wpv-post-id item="@relationship-slug.parent"]

Where:
- Replace relationship-slug with your original post type relationship slug.

Relevant Documentation:

This support ticket is created 6 years, 3 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 6 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1079497

Tell us what you are trying to do?

I want to get the Post Object of the Post that is being queried hidden link using toolset shortcode. In wordpress function it's just get_queried_object(); see this link screenshot hidden link

because I want to get the post object ID of the that link so that I can use it on the answer form

What is the link to your site?
hidden link

#1079642

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I still do not get your question. using [wpv-post-id] shortcode you can get the post ID of currently displayed page/post.

If you want to have post object - you should create a custom shortcode and return whatever thing you want to return as per your need.

For example:

function func_access_post_object($atts){
    global $post;

    // return post Id
   return $post->ID;

}
add_shortcode("access-post-object", "func_access_post_object");

And use above shortcode as given under:

[access-post-object]   == should display the ID of post

If I misunderstood anything here, Please share more details of your issue so I can guide you in right direction.

#1087318

How do you do this without having custom function? Can we do this like Parent / Child relationship like there is some connection between Question Custom Post type and Answers Custom Post type?

#1087377

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - to access the parent ID when you have created post type relationship with Types plugin version 3.x.x - you can use the following shortcode:

[wpv-post-id item="@relationship-slug.parent"]

Where:
- Replace relationship-slug with your original post type relationship slug.