Created
April 1, 2020 20:18
-
-
Save hmbashar/5c34805b8f243213fefc386040cfc34b to your computer and use it in GitHub Desktop.
How to add column into post list in the wordpress dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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