manage_posts_columns

Home » Hooks » manage_posts_columns

The manage_posts_columns hook is used to add or remove columns from the post listing table in the WordPress admin panel. This hook allows developers to customize the display of post information by defining new columns or removing existing ones.

By default, the post listing table in the WordPress admin shows columns such as Title, Author, Categories, Tags, Comments, and Date. However, sometimes you may need to add or remove certain columns to better suit your needs.

To add a new column, you can use the manage_posts_columns hook to define the column name and content. To remove a column, you can simply unset the corresponding array key.

Here’s an example usage code that demonstrates how to add a new column to the post listing table:

function custom_post_column($columns) {
   $columns['featured_image'] = __( 'Featured Image', 'text-domain' );
   return $columns;
}
add_filter( 'manage_posts_columns', 'custom_post_column' );

In this example, we’re adding a new column called "Featured Image" to the post listing table. The function custom_post_column adds the new column to the $columns array and returns it. Finally, the add_filter function is used to hook into the manage_posts_columns hook and apply our custom post column.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.