manage_posts_custom_column

Home » Hooks » manage_posts_custom_column

The manage_posts_custom_column hook is a WordPress action hook that allows developers to customize the columns of a post or page in the WordPress admin panel. This hook is called for each custom column that has been added to the post list table.

Essentially, this hook allows developers to add custom data to a post or page’s admin panel. For instance, a developer could use this hook to display metadata associated with a post, such as the post’s author or publication date.

Here is an example usage code for the manage_posts_custom_column hook:

function my_custom_column_content($column_name, $post_id) {
    if ($column_name == 'my_custom_column') {
        echo "This is my custom column's content for post " . $post_id;
    }
}
add_action('manage_posts_custom_column', 'my_custom_column_content', 10, 2);

In this example, we’re defining a custom column called ‘my_custom_column’, and then using the manage_posts_custom_column hook to display data in that column. The ‘my_custom_column_content’ function is called for each post in the list table, and checks to see if the current column is our custom column. If so, it echoes out our custom content. The ‘add_action’ function is then used to attach our function to the manage_posts_custom_column hook.

Learn More on WordPress.org

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