apply_filters( "manage_{$post_type}_posts_columns", string[] $post_columns )

Filters the columns displayed in the Posts list table for a specific post type.


Description

The dynamic portion of the hook name, $post_type, refers to the post type slug.

Possible hook names include:

  • manage_post_posts_columns
  • manage_page_posts_columns

Top ↑

Parameters

$post_columns string[]
An associative array of column headings.

Top ↑

More Information

$post_columns is an associative array of “column name” ⇒ “label”. The “column name” is passed to callback functions to identify the column. The “label” is shown as the column header.

Built-in Column Types:

Note: Listed in order of appearance. By default, all columns supported by the post type are shown.

cb: Checkbox for bulk actions.

title: Post title. Includes “edit”, “quick edit”, “trash” and “view” links. If $mode (set from $_REQUEST[‘mode’]) is ‘excerpt’, a post excerpt is included between the title and links.

author: Post author.

categories: Categories the post belongs to.

tags: Tags for the post.

comments: Number of pending comments.

date: The date and publish status of the post.


Top ↑

Source

File: wp-admin/includes/class-wp-posts-list-table.php. View all references

return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );


Top ↑

Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Andrija Naglic
    function my_custom_columns_list($columns) {
        
        unset( $columns['title']  );
        unset( $columns['author'] );
        unset( $columns['date']   );
        
        $columns['product_number']     = 'Product Number';
        $columns['custom_handler']     = 'Nice name';
    
    	
        return $columns;
    }
    add_filter( 'manage_product_posts_columns', 'my_custom_columns_list' );

    For further management of columns, check:

    https://developer.wordpress.org/reference/hooks/manage_post-post_type_posts_custom_column/
    To set the custom column values

    https://developer.wordpress.org/reference/hooks/list_table_primary_column/
    To set the primary (default) column

  2. Skip to note 2 content
    Contributed by Steven Lin

    Example migrated from Codex:

    Add Columns

    Suppose you have a ‘books’ custom post type and you want to add the publisher and book author in the edit page but remove the post author.

    function add_book_columns($columns) {
        unset($columns['author']);
        return array_merge($columns, 
                  array('publisher' => __('Publisher'),
                        'book_author' =>__( 'Book Author')));
    }
    add_filter('manage_book_posts_columns' , 'add_book_columns');
  3. Skip to note 3 content
    Contributed by Shashikant Yadav

    To reorder columns

    function wpdocs_item_columns( $columns ) {
        $custom_col_order = array(
            'cb' => $columns['cb'],
            'title' => $columns['title'],
            'rating' => __( 'Ratings', 'textdomain' ),
            'date' => $columns['date']
        );
        return $custom_col_order;
    }
    add_filter( 'manage_item_posts_columns', 'wpdocs_item_columns' );

    Just use the $custom_col_order array to reorder the columns in {$post_type}.
    NOTE: in the above example, item is the custom post type

  4. Skip to note 4 content
    Contributed by Steven Lin

    Example migrated from Codex:

    Replace Columns

    Here’s another example that completely replaces the columns, rather than adding and removing specific ones.

    function set_book_columns($columns) {
        return array(
            'cb' => '<input type="checkbox" />',
            'title' => __('Title'),
            'comments' => '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>',
            'date' => __('Date'),
            'publisher' => __('Publisher'),
            'book_author' =>__( 'Book Author')
        );
    }
    add_filter('manage_book_posts_columns' , 'set_book_columns');
  5. Skip to note 5 content
    Contributed by gregrobson

    Be careful with your choice of column name.

    I decided to use tags as a column name (key on the array) and spent a few minutes wondering why no value was appearing for the column. The function to pull out the data wasn’t even called. It is of course, a default field on the post type and the fuction won’t get called WP uses its default value.

    Prefixing the column fixed the issue.

You must log in before being able to contribute a note or feedback.