Skip to content

Instantly share code, notes, and snippets.

@hmbashar
Created April 1, 2020 20:18
Show Gist options
  • Save hmbashar/5c34805b8f243213fefc386040cfc34b to your computer and use it in GitHub Desktop.
Save hmbashar/5c34805b8f243213fefc386040cfc34b to your computer and use it in GitHub Desktop.
How to add column into post list in the wordpress dashboard
// ADD NEW COLUMN
function suga_columns_head($defaults) {
$defaults['featured_image'] = 'Post ID';
return $defaults;
}
// show value in the new column
function suga_columns_content($column_name, $post_ID) {
if ($column_name == 'featured_image') {
echo 'Post ID: <strong>'.get_the_ID().'</strong>';
}
}
add_filter('manage_posts_columns', 'suga_columns_head');
add_action('manage_posts_custom_column', 'suga_columns_content', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment