I have added this code to my theme to add a new colmum for showing the featured image in the dashboard post page colmum. It's working in wordpress default post page, but not in custom post type (my custom post name is photo_gallery).

add_filter('manage_posts_columns', 'posts_columns', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 3);
function posts_columns($defaults){
    $defaults['riv_post_thumbs'] = __('Thumbnail');
    return $defaults;
function posts_custom_columns($column_name, $id){
   if($column_name === 'riv_post_thumbs'){
        echo the_post_thumbnail( array('292, 292') );

How can I show this custom column as first in my custom post type overview?

  • Put your code in backticks please. Use the {} for code when adding code in your question Feb 21, 2014 at 10:51
  • What is backtricks.I can not understand.I put my code between {} but it show nothing.
    – S.k.joy
    Feb 21, 2014 at 12:13
  • 1
    @PieterGoosen talks about the buttons right above the text editor field. One button symbolize two bracket »{}«. Click on the button, and the editor prepares the code-input for you. (Which is just an indentation of for spaces). To mark up inline-code you should wrap it in »Backticks« (or »Back quotes«): ```
    – David
    Feb 21, 2014 at 13:38

1 Answer 1


I'm not sure what exactly does not work for your custom post type. There are two possible cases:

  • Your custom post type photo_gallery is hierarchical. That would mean, neither (column head and values) are shown.
  • Your post type is not hierarchical but does not support featured images.

Anyway, if you want to add the thumbnail only to your custom post type this code should do it:

add_filter( 'manage_photo_gallery_posts_columns', 'wpse_135433_posts_columns' );
add_action( 'manage_photo_gallery_posts_custom_column', 'wpse_135433_posts_custom_columns', 10, 2 );

function wpse_135433_posts_columns( $defaults ){

    $defaults = array_merge(
        array( 'riv_post_thumbs' => __( 'Thumbnail' ) ),

    return $defaults;

function wpse_135433_posts_custom_columns( $column_name, $id ) {

   if ( $column_name === 'riv_post_thumbs' ) {
        echo the_post_thumbnail( array('292, 292') );

By the way, you should use prefixes on your custom functions to avoid collisions. (In this example I used the prefix wpse_135433_.

The function wpse_135433_posts_columns() attaches the column at the first position to the list of columns $defaults.

If you want to use this functionality on more than your custom post type you should use

add_filter( 'manage_posts_columns', 'wpse_135433_posts_columns', 10, 2 );
add_action( 'manage_posts_custom_column', 'wpse_135433_posts_custom_columns', 10, 2 );

for non hierarchical post types and

add_filter( 'manage_pages_columns', 'wpse_135433_posts_columns', 10, 2 );
add_action( 'manage_pages_custom_column', 'wpse_135433_posts_custom_columns', 10, 2 );

for hierarchical post types. The second parameter passed to the manage_posts_columns filter is the current post type.

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