Display WordPress page ID's in the admin
This is a quick tip to display the page ID next to the page title in the WordPress admin without the need for any plugins. Simply add this snippet to your themes functions.php
file:
// Set columns to be used in the Pages section
function custom_set_pages_columns($columns) {
return array(
'cb' => '<input type="checkbox" />',
'page_id' => __('ID'),
'title' => __('Title'),
'author' => __('Author'),
'date' => __('Date'),
);
}
// Add the ID to the page ID column
function custom_set_pages_columns_page_id( $column, $post_id ) {
if ($column == 'page_id'){
echo $post_id;
}
}
// Add custom styles to the page ID column
function custom_admin_styling() {
echo '<style type="text/css">',
'th#page_id{width:60px;}',
'</style>';
}
// Add filters and actions
add_filter('manage_edit-page_columns' , 'custom_set_pages_columns');
add_action( 'manage_pages_custom_column' , 'custom_set_pages_columns_page_id', 10, 2 );
add_action('admin_head', 'custom_admin_styling');
This then will create a new column in the Pages section which has the page ID in.
Post with example image: http://markgoodyear.com/2013/07/display-page-id-wordpress-admin-area/
Written by Mark Goodyear
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Wordpress
Authors
Related Tags
#wordpress
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#