Skip to content

Instantly share code, notes, and snippets.

@eksiscloud
Last active November 5, 2019 12:07
Show Gist options
  • Save eksiscloud/057bed1d4a12d74c7863bd556ea8bbaa to your computer and use it in GitHub Desktop.
Save eksiscloud/057bed1d4a12d74c7863bd556ea8bbaa to your computer and use it in GitHub Desktop.
Wordpress: Show ID of post/page at admin
add_filter('manage_posts_columns', 'posts_columns_id', 5);
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns_id', 5);
add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
$defaults['wps_post_id'] = __('ID');
return $defaults;
}
function posts_custom_id_columns($column_name, $id){
if($column_name === 'wps_post_id'){
echo $id;
}
}
@eksiscloud
Copy link
Author

Made for linking purposes. The original snippet is from here: https://www.isitwp.com/add-post-id-to-posts-pages-admin-columns/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment