getButterfly Logo getButterfly code wrangling since 2005

WordPress Custom Columns

Here’s how to add additional custom columns to any post type in WordPress. This applies to the admin editing screen. Note that I am using ACF in the example below, but you can easily switch get_field() with get_post_meta($post->ID, 'key_name', true). Also, I am using event as the post type slug.

function gb1475228224_page_columns($columns) {
    $columns = array(
        'cb'    => '<input type="checkbox" />',
        'title' => 'Title',
        'date'  => 'Date',
        'cdate' => 'Event Date',
        'ctime' => 'Event Time',

    return $columns;

function gb1475228224_custom_columns($column) {
    global $post;

    if($column == 'thumbnail') {
        echo wp_get_attachment_image( get_field('page_image', $post->ID), array(200,200) );
    } else if($column == 'cdate') {
        echo 'Event Date:<br>' . get_field('booking_date', $post->ID);
    } else if($column == 'ctime') {
        echo 'Event Time:<br>' . get_field('booking_time', $post->ID);

add_action("manage_posts_custom_column", "gb1475228224_custom_columns");
add_filter("manage_edit-event_columns", "gb1475228224_page_columns");

That is all. Enjoy.

Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

Leave a reply