Problem:
The issue here is that the user wanted to display their parent post information in the Toolset Admin Column for the custom post type.
Solution:
This can be done by using the code below.
//Replace the following /* cptslug - replace with custom post type slug parent - replace with parent cpt slug child - replace with child cpt slug Column Name - replace with the desired column name. */ //Add custom column add_filter('manage_edit-cptslug_columns', 'my_columns_head'); function my_columns_head($defaults) { $defaults['Parent'] = 'Column Name';//edit return $defaults; } //Add rows data add_action( 'manage_cptslug_posts_custom_column' , 'my_custom_column', 10, 2 ); function my_custom_column($column, $post_id ){ switch ( $column ) { case 'Parent': $parent_id = toolset_get_related_post( $post_id, array( 'parent', 'child' ) );//edit if($parent_id){ echo get_the_title( $parent_id ); } else { echo 'No Parent Found'; } break; } }
This code can be added to your Toolset custom code settings at Toolset -> Settings -> Custom code and then activate it once you've added the code.
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 |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 5 replies, has 2 voices.
Last updated by 3 years, 3 months ago.
Assisted by: Shane.