Adding additional column for the WPCargo shipment post type is very simple. You can use “default_wpcargo_columns” filter for the column header and “manage_wpcargo_shipment_posts_custom_column” action for the column data.
Copy and paste the following codes on your child theme’s functions.php file
// This filter will add custom header in shipment Header
add_filter('default_wpcargo_columns', function( $column_header ){
$column_header['my_custom_header'] = 'My Custom Header';
return $column_header;
});
After adding custom header column, use “manage_wpcargo_shipment_posts_custom_column” hook to add column data based on the shipment id.
See this sample code to display the data.
add_action( 'manage_wpcargo_shipment_posts_custom_column', function( $column, $post_id ){
// make sure that the column key will the same value with your column header a key
// in this example is "my_custom_header"
if( $column == 'my_custom_header' ){
// Display the meta key using the "get_post_meta" function to display data
echo get_post_meta( $post_id, 'my_custom_header', true );
}
}, 10, 2 );