I added a custom column to a custom post type:
add_filter('manage_posts_columns', 'custom_columns', 10);
add_action('manage_posts_custom_column', 'custom_columns_thumb', 10, 2);
function custom_columns($columns) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'categories' => 'Categories', // not showing
'thumb' => __('Thumb'),
'date' => __( 'Date' )
);
return $columns;
}
function custom_columns_thumb($column_name, $id){
if($column_name === 'thumb') {
echo the_post_thumbnail( 'thumb' );
}
}
The custom column “thumb” shows properly but the category is no longer displayed. Please see image.

What is causing this? The categories show if I remove the custom columns.
Here I tested this code and its working fine and steps here.
-
I am just creating a dummy custom_post_type
here book
with the following code.
function kv_custom_post_books() {
$args = array(
'public' => true,
'label' => 'Books',
'taxonomies' => array('category', 'post_tag') ,
'supports' => array( 'title', 'editor', 'thumbnail' )
);
register_post_type( 'book', $args );
}
add_action( 'init', 'kv_custom_post_books' );
Here i am not sure, you used this line. 'taxonomies' => array('category', 'post_tag')
. This one gets you the default categoires to your custom post type.
-
Now we will rewrite your action hook here. and we use the same functions no change in it.
add_filter('manage_edit-book_columns', 'custom_columns', 10);
add_action('manage_posts_custom_column', 'custom_columns_thumb', 10, 2);
function custom_columns($columns) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'categories' => 'Categories', // not showing
'thumb' => __('Thumb'),
'date' => __( 'Date' )
);
return $columns;
}
function custom_columns_thumb($column_name, $id){
if($column_name === 'thumb') {
echo the_post_thumbnail( 'thumb' );
}
}
Note : I just edited only one line in your code. add_filter('manage_edit-book_columns', 'custom_columns', 10);
. We have to specify your custom post type in your action hook. This is the ultimate thing here . manage_edit-book_columns
Instead of default one we have to specify the custom post type name here.
Here I attached a screenshot for you,
