Bootstrap Templates Bundle

Monday, August 26, 2013

How to add a ID column into wordpress Posts and pages

Add these below code to functions.php file  and after adding visit
../wp-admin/edit.php?post_type=page
and ../wp-admin/edit.php



/* Add Post ID column */
add_filter('manage_posts_columns', 'posts_columns_id', 5);
function posts_columns_id($defaults){
    $defaults['wps_post_id'] = 'ID';
    return $defaults;
}
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_custom_id_columns($column_name, $id){
        if($column_name === 'wps_post_id'){
                echo $id;
    }
}
add_action('admin_head', 'id_column_style');
function id_column_style() {
    echo '<style type="text/css">.column-wps_post_id{width:5%;}</style>';
}


/* Add Page ID column */
add_filter('manage_pages_columns', 'pages_columns_id', 5);
function pages_columns_id($defaults){
    $defaults['wps_page_id'] = 'ID';
    return $defaults;
}
add_action('manage_pages_custom_column', 'pages_custom_id_columns', 5, 2);
function pages_custom_id_columns($column_name, $id){
        if($column_name === 'wps_page_id'){
                echo $id;
    }
}
add_action('admin_head', 'id_column_style');
function ids_column_style() {
    echo '<style type="text/css">.column-wps_page_id{width:5%;}</style>';
}

No comments:

Post a Comment

Nightery - Night Club WordPress Theme

Nightery - Night Club WordPress Theme Nightery – Night Club WordPress Theme is an awesome design idea for your Night Club, Conce...