WordPress.org

Ready to get started?Download WordPress

Codex

Plugin API/Filter Reference/manage $post type posts columns

Contents

Description

manage_${post_type}_posts_columns is a filter applied to the columns shown when listing posts of a custom type.

Parameters

$columns
(array) (required) An array of column name ⇒ label. The name is passed to functions to identify the column. The label is shown as the column header.
Default: None

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.


Examples

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');

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'),
        'date' => __('Date'),
        'publisher' => __('Publisher'),
        'book_author' =>__( 'Book Author')
    );
}
add_filter('manage_book_posts_columns' , 'set_book_columns');

Note the header for the 'cb' column is a checkbox, so that the checked posts can be toggled between all and none.

Change Log

Since: 3.1

Source File

manage_${post_type}_posts_columns is applied by WP_Posts_List_Table->get_columns in wp-admin/includes/class-wp-posts-list-table.php.

Related

Actions

Filters