How to add New custom column to WordPress post list table

Spread the Knowledge

To add a new custom column to the WordPress posts list overview table, you need to use the “manage_{$post_type}_posts_columns” filter. In this filter the {$post_type} you can use default post types, like post, page etc

add_filter( 'manage_post_posts_columns', 'w3_add_new_custom_column', 20 );
function w3_add_new_custom_column( $columns ) {
    $columns['custom_column_id'] = 'My Custom Column';
    return $columns;

Once you add column to your to the posts listing table, now you need to show the column value, for this you need to use “manage_{$post_type}s_custom_column” action.

function w3_custom_column_content($column_name, $post_id) {
    if ($column_name == 'custom_column_id') {
        echo 'Custom Column Content';
       //If you want to show costom meta data, then use the below line
       //echo get_post_meta( $post_id,'custome_meta_data' , true);
add_action( 'manage_posts_custom_column', 'w3_custom_column_content', 10, 2 );

The above code will go to your theme’s functions.php file, or you can create your own plugin and add this code.To create you own plugin for the above code, please read here.

Spread the Knowledge