Custom column for post type

When creating custom post types, the standard columns(title, author, date etc.) might not be enough for your needs, and this snippet will help you to create your own.

You can add the custom columns for your custom post types by adding this to functions.php. Remember to change POSTTYPE to your post type slug!

Code Snippet:

add_action('manage_POSTTYPE_posts_columns', 'posts_column_hello', 10);
add_action('manage_POSTTYPE_posts_custom_column', 'posts_custom_column_hello', 10, 2);
function posts_column_hello($defaults){
    $defaults&#91;'post_hello'&#93; = __('Hello World');
    return $defaults;
function posts_custom_column_hello($column_name, $post_id){
    switch($column_name) {
        case 'post_hello':
            echo 'hello world'

Posted in Pure hacks