How do I add a new column in WordPress? (Step-by-Step Guide)

If you run a blog or website that’s frequently updated, it’s useful to know when each post was last changed. By default, WordPress only shows the publish date in the admin area — but with just a few lines of code, you can add a “Last Updated” column that’s also sortable.

In this guide, you’ll learn how to display a “Last Updated” column on your Posts > All Posts screen in the WordPress dashboard.

💡 No coding experience needed! You can simply copy and paste the code below into your theme’s functions.php file or, even better, use a plugin like Code Snippets to safely manage the code without editing your theme directly.


Step-by-Step: Adding the “Last Updated” Column

1. Create the new column

This first function adds a column titled “Last Updated” to your list of posts in the WordPress admin.

function custom_add_last_updated_column( $columns ) {
    $columns['last_updated'] = 'Last Updated';
    return $columns;
}
add_filter( 'manage_posts_columns', 'custom_add_last_updated_column' );

2. Display the modified date

Next, we’ll populate the new column with the date each post was last updated using get_the_modified_date().

function custom_show_last_updated_column( $column_name, $post_id ) {
    if ( 'last_updated' === $column_name ) {
        echo esc_html( get_the_modified_date( 'M d, Y', $post_id ) );
    }
}
add_action( 'manage_posts_custom_column', 'custom_show_last_updated_column', 10, 2 );

3. Make the column sortable

Here, we tell WordPress that the “Last Updated” column can be sorted by the post’s modified date.

function custom_sortable_last_updated_column( $columns ) {
    $columns['last_updated'] = 'modified';
    return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'custom_sortable_last_updated_column' );

4. Enable sorting functionality

This final step ensures that sorting works correctly when you click the “Last Updated” header.

function custom_sort_last_updated_column( $query ) {
    if ( ! is_admin() || ! $query->is_main_query() ) {
        return;
    }

    if ( $query->get( 'orderby' ) === 'modified' ) {
        $query->set( 'orderby', 'modified' );
    }
}
add_action( 'pre_get_posts', 'custom_sort_last_updated_column' );

🔍 Quick Breakdown

  • manage_posts_columns – Adds the custom column.
  • manage_posts_custom_column – Displays the last modified date in that column.
  • manage_edit-post_sortable_columns – Makes the column sortable.
  • pre_get_posts – Adjusts the query so sorting works by modified date.

✅ What You’ll Get

Once the code is added:

  • A “Last Updated” column appears beside your post titles.
  • You can click the column header to sort posts by their most recent update date, ascending or descending.

🛡️ Pro Tips

  • Always use a child theme or the Code Snippets plugin to prevent changes from being lost during theme updates.
  • You can easily adapt this for Pages or Custom Post Types — just replace manage_posts_columns with the appropriate hook (for example, manage_page_columns).

🙋 Need a Hand?

If you’d like help applying this to Pages or other post types, or you’re new to adding custom code, don’t hesitate to ask or leave a comment!


Tags: #ManagePostsColumns #WordPressAdminCustomization

Posted in Web TutorialsTags:
Write a comment