You're at the very top of the page

Ryan Ormrod - Bespoke WordPress and WooCommerce solutions

When creating custom post types we tend to need to insert additional columns in our WordPress admin backend to improve post management. We can
add and unset any columns we wish, by using custom filters and actions.

Say we created a custom post type called services, to get our custom column headers
we would need to create a filter called ‘manage_services_posts_column’ and bind it to a function that takes the default columns as a parameter. It’s important to include the word ‘services in the filter name. Next, we can unset columns (as they’re an associative array) and create new columns by adding a new key => value to the array.

add_filter( 'manage_services_posts_columns', 'set_custom_edit_services_columns' ); 

function set_custom_edit_services_columns($columns) {  
$columns['service_type'] = __('Service type');  
return $columns; 

Now we need to insert the data for this new column that we’ve called ‘service_type’ => ‘Service type’. We do this by creating a new action and binding it
to a function which takes the columns array and the post id of the current row as parameters. This function is where we need to check for our ‘service_type’ array
key, and when it has its turn, we can echo whatever information we need.

add_action( 'manage_services_posts_custom_column' , 'custom_services_column', 10, 2 ); 

function custom_services_column( $column, $post_id ) { 

 switch ( $column ) { 

  case 'service_type' : 

   // echo get_field('service_type', $post_id); 

   echo 'hello this is a test'; 




And that’s all that we need to do!