Answer the question
In order to leave comments, you need to log in
How to display a sortable column with post IDs in the WordPress admin?
Good afternoon.
I'm trying to display a sortable column with post IDs in the wordpress admin.
/* Adding a column with IDs of posts and pages to the admin */ Source
function true_id($args){
$args['post_page_id'] = 'ID';
return $args;}
function true_custom($column, $id){
if($column === 'post_page_id'){
echo $id; }}
add_filter('manage_pages_columns', 'true_id');
add_action('manage_pages_custom_column', 'true_custom',10, 2);
add_filter('manage_posts_columns', 'true_id');
add_action('manage_posts_custom_column', 'true_custom',10, 2);
add_filter('manage_edit-post_sortable_columns', 'add_views_sortable_column');
function add_views_sortable_column($sortable_columns){
$sortable_columns['post_page_id'] = 'views_views';
return $sortable_columns;}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question