Using WordPress ‘manage_{$post_type}_posts_columns’ PHP filter

The manage_{$post_type}_posts_columns WordPress PHP filter allows you to modify the columns displayed in the Posts list table for a specific post type.

Usage

add_filter( 'manage_{$post_type}_posts_columns', 'your_custom_function' );

function your_custom_function( $post_columns ) {
    // your custom code here
    return $post_columns;
}

Parameters

  • $post_columns (string[]): An associative array of column headings.

More information

See WordPress Developer Resources: manage_{$post_type}_posts_columns

Examples

Add a custom column for the ‘price’ meta field in the products post type

This example adds a ‘Price’ column to the products post type list table.

add_filter( 'manage_products_posts_columns', 'add_price_column' );

function add_price_column( $post_columns ) {
    $post_columns['price'] = __( 'Price', 'textdomain' );
    return $post_columns;
}

Remove the ‘author’ column from the posts list table

This example removes the ‘Author’ column from the posts list table.

add_filter( 'manage_post_posts_columns', 'remove_author_column' );

function remove_author_column( $post_columns ) {
    unset( $post_columns['author'] );
    return $post_columns;
}

Reorder columns in the custom post type ‘events’

This example reorders the columns in the ‘Events’ custom post type list table.

add_filter( 'manage_events_posts_columns', 'reorder_columns' );

function reorder_columns( $post_columns ) {
    $new_columns = array(
        'cb' => $post_columns['cb'],
        'title' => __( 'Event Title', 'textdomain' ),
        'date' => __( 'Event Date', 'textdomain' ),
    );

    return $new_columns;
}

Change the ‘Title’ column label in the pages list table

This example changes the label of the ‘Title’ column in the pages list table.

add_filter( 'manage_page_posts_columns', 'change_title_column_label' );

function change_title_column_label( $post_columns ) {
    $post_columns['title'] = __( 'Page Name', 'textdomain' );
    return $post_columns;
}

Add a custom column for the ‘rating’ meta field in the movies post type

This example adds a ‘Rating’ column to the movies post type list table.

add_filter( 'manage_movies_posts_columns', 'add_rating_column' );

function add_rating_column( $post_columns ) {
    $post_columns['rating'] = __( 'Rating', 'textdomain' );
    return $post_columns;
}