Last updated on September 13, 2023

Add Admin Column to Custom Post Type

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Add custom admin columns to custom post type.

If you have added custom post types to your WordPress site, you might be interested in adding custom columns to the admin are for that post type. Here’s how you can do that:

function wpsnippets_custom_columns_header( $columns ) {
    $columns['custom_column'] = __( 'Custom Column', 'wpsnippets' );
    return $columns;
}

add_filter( 'manage_{$post_type}_posts_columns', 'wpsnippets_custom_columns_header' );

function wpsnippets_custom_columns_content( $column_name, $post_id ) {
    
   if ( $column_name == 'custom_column' ) {

        // Add your custom column content here.
        echo 'Custom Column Content';
    }
}

add_action( 'manage_{$post_type}_posts_custom_column', 'wpsnippets_custom_columns_content', 10, 2 );

Make sure to replace the $post_type in manage_{$post_type}_posts_columns and manage_{$post_type}_posts_custom_column, where $post_type is the slug of your custom post type.

Last updated on September 13, 2023. Originally posted on May 3, 2023.

Leave a Reply