How to Add Custom Columns to the WordPress Admin Post List
The default WordPress post list in the admin dashboard shows columns like Title, Author, Categories, and Date. However, you may want to display additional information, such as a custom field, featured image, or SEO score. WordPress allows you to add custom columns to the post list using filters and actions.
Step 1: Register a New Column
Use the manage_posts_columns filter (for posts) or manage_{post_type}_posts_columns for custom post types.
// Add a custom column to the post list
function my_add_custom_columns($columns) {
$columns['featured_image'] = 'Featured Image';
$columns['my_custom_field'] = 'Custom Field';
return $columns;
}
add_filter('manage_posts_columns', 'my_add_custom_columns');
This example adds two new columns: one for the featured image and one for a custom field.
Step 2: Populate the Column with Data
Next, use the manage_posts_custom_column action to output the content for each row.
// Populate the custom columns
function my_custom_column_content($column, $post_id) {
if ($column === 'featured_image') {
$thumb = get_the_post_thumbnail($post_id, array(60, 60));
echo $thumb ? $thumb : '—';
}
if ($column === 'my_custom_field') {
$value = get_post_meta($post_id, 'my_custom_field', true);
echo $value ? esc_html($value) : '—';
}
}
add_action('manage_posts_custom_column', 'my_custom_column_content', 10, 2);
This code displays a small thumbnail of the featured image and the value of a custom field called my_custom_field.
Step 3: Make the Column Sortable (Optional)
You can also make your custom column sortable by using the manage_edit-post_sortable_columns filter.
// Make custom field column sortable
function my_sortable_custom_column($columns) {
$columns['my_custom_field'] = 'my_custom_field';
return $columns;
}
add_filter('manage_edit-post_sortable_columns', 'my_sortable_custom_column');
// Define the sorting behavior
function my_custom_orderby($query) {
if (!is_admin()) return;
$orderby = $query->get('orderby');
if ($orderby === 'my_custom_field') {
$query->set('meta_key', 'my_custom_field');
$query->set('orderby', 'meta_value');
}
}
add_action('pre_get_posts', 'my_custom_orderby');
This makes the “Custom Field” column sortable by its meta value.
Step 4: Apply to Custom Post Types
If you want to add columns to a custom post type (e.g., product), replace manage_posts_columns with:
manage_product_posts_columns
And use:
manage_product_posts_custom_column
This ensures the columns only apply to that custom post type.
Summary
- Use
manage_{post_type}_posts_columnsto register new columns. - Fill those columns with content using
manage_{post_type}_posts_custom_column. - Optionally make columns sortable with
manage_edit-{post_type}_sortable_columnsandpre_get_posts.
With these steps, you can display any data you need in the WordPress admin post list, making it easier to manage content at a glance.
🎨 Want to learn more? Visit our WordPress Customization Hub for tips and advanced techniques.