Add custom column in custom post type edit page

I am using the Content Scheduler plugin to control the post expire. The plugin will add a expiry date column on the wp-admin/edit.php in page and post. However it doesn’t show in custom post type page list.

So I take a look into plugin codes and found this which believe are the one that control the column in the page list.

Read More
add_action ( 'manage_posts_custom_column', array( $this, 'cs_show_expdate' ) );
add_filter ('manage_posts_columns', array( $this, 'cs_add_expdate_column' ) );

Thus, I tried to add another filter for the custom post type in the plugin file, like these:

add_action ( 'manage_cpt_posts_custom_column', array( $this, 'cs_show_expdate' ));
add_filter ('manage_cpt_posts_columns', array( $this, 'cs_add_expdate_column' ) );

where cpt is the custom post type, however this won’t work, any idea why?

By the way, I know it is not a good approach to alter the plugin core codes, but I don’t know if I can hook it in functions.php. Anyone know how to do this? thanks.

Related posts

Leave a Reply

1 comment

  1. the correct hooks are manage_{$post_type}_posts_custom_column action hook to display the column and manage_edit-{$post_type}_columns filter hook to add the column, so try,

    add_action ( 'manage_cpt_posts_custom_column', array( $this, 'cs_show_expdate' ));
    add_filter ('manage_edit-cpt_columns', array( $this, 'cs_add_expdate_column' ) );