0

how can I add an extra admin column with the Status of posts like Below Image. i know admin column plugin for this work but i don't want to use any plugin..so please suggest me if there any code to add an extra admin column with the Post Status

Smale image

2 Answers 2

1

The last function doesn't work. Use this instead to fill the status column:

// Add the data to the post columns:
add_action( 'manage_post_posts_custom_column' , 'custom_post_column', 10, 2 );
function custom_post_column( $column, $post_id ) {
    if ( $column == "status" ) {
        echo get_post_status($post_id);
    }
}
0

This is the simplest use of adding custom columns:

// Add the custom columns to the post type:
add_filter( 'manage_post_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
    $columns['status'] = __( 'Status', 'your_text_domain' );  // or simply "Status";
    return $columns;
}

// Add the data to the post columns:
add_action( 'manage_post_posts_custom_column' , 'custom_post_column', 10, 2 );
function custom_post_column( $column, $post_id ) {
    if ( $column == "status" ) {
               $p_status = get_post_meta($post->ID, 'status', true);
                echo $p_publish;
    }
}

Of course you could also do this column sortable and so on! Not tested, but it should work, you've got the point

You could also check these links, discribing almost the same question as yours:

Add custom columns: http://www.deluxeblogtips.com/add-custom-column/

Add sortable columns: https://wordpress.org/support/topic/admin-column-sorting/

1
  • This Code is worked to add status Column at my post page but post Status is not showing is Status Column. Aug 1, 2021 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.