How to Add columns in Admin Screen

If You want to add custom column in admin for page, post or custom post – it’s easy to make it.

First must add a title for column and this is the code witch to use in your function.php :

add a hook:

add_filter('manage_posts_columns', 'custom_column_head');

and add function ‘custom_column_head’ :

function custom_column_head($defaults) {
    global $post;
    $post_type = get_post_type($post->ID);
    if ($post_type == 'your_post_type_here'):// this is in case to show only in one custom post type
        $defaults['your_title_here'] = __('Your Title Here');
    return $defaults;

Now we have new custom column title in our custom post type.If we use in posts or pages the if statement will be different.

Now we must show some in our column. Add a hook:

add_action('manage_posts_custom_column', 'custom_columns_content', 10, 2);

And function ‘custom_columns_content’ :

function custom_columns_content($column_name, $post_ID) {
    $post_type = get_post_type($post_ID);
    if ($post_type == 'your_post_type'):
        if ($column_name == 'your_title_here'):
            echo 'Here Is this witch you whant to show';

I Use this in my projects. Here is one of them – Link

One thought on “How to Add columns in Admin Screen

Leave a Reply