Skip Navigation

[Resolved] Creating an admin custom column showing name of parent CPT

This support ticket is created 7 years, 2 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 1 reply, has 2 voices.

Last updated by Minesh 7 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#566218
Screen Shot 2017-09-03 at 11.27.27.png

I have two custom posts : "emploi" and "enterprise"

There is a parent-chhild relationship between both, where "enterprise" is the parent.

In the dashboard, when looking at "All the Emplois", I would like to add a column that displays the name of the parent, in this case, it would be the post_title of "enterprise".

I've managed to create the column, but am not able to find the code that will populate the rows...

I feel I'm close, can you tell me what's not right in my last code block 🙂

#566329

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

you want to display the parent post title using the PHP. Please check the following Doc:
=> https://toolset.com/documentation/customizing-sites-using-php/displaying-parent-posts/
[Section: "Displaying standard post data"]

you can get the parent post ID using the following function:

$enterprise_id = wpcf_pr_post_get_belongs( $post_id , 'enterprise' );
$enterprise_post = get_post( $enterprise_id );
$enterprise_title = $enterprise_post ->post_title;