Using WordPress ‘manage_{$this->screen->taxonomy}_custom_column’ PHP filter

The manage_{$this->screen->taxonomy}_custom_column WordPress PHP filter allows you to modify the displayed columns in the terms list table. The dynamic part of the filter name, $this->screen->taxonomy, refers to the slug of the current taxonomy.

Usage

add_filter('manage_{$this->screen->taxonomy}_custom_column', 'your_custom_function', 10, 3);

function your_custom_function($string, $column_name, $term_id) {
    // your custom code here
    return $string;
}

Parameters

  • $string (string) – Custom column output. Default empty.
  • $column_name (string) – Name of the column.
  • $term_id (int) – Term ID.

More information

See WordPress Developer Resources: manage_{$this->screen->taxonomy}_custom_column

Examples

Add a custom column for categories

Add a custom column named “Custom” for categories and display the term’s ID:

add_filter('manage_category_custom_column', 'add_custom_category_column', 10, 3);

function add_custom_category_column($string, $column_name, $term_id) {
    if ('Custom' === $column_name) {
        $string = $term_id;
    }
    return $string;
}

Add a custom column for post tags

Add a custom column named “Custom” for post tags and display the term’s slug:

add_filter('manage_post_tag_custom_column', 'add_custom_post_tag_column', 10, 3);

function add_custom_post_tag_column($string, $column_name, $term_id) {
    if ('Custom' === $column_name) {
        $term = get_term($term_id, 'post_tag');
        $string = $term->slug;
    }
    return $string;
}

Change the output of the description column for categories

Change the output of the “Description” column for categories to display “No Description” when it is empty:

add_filter('manage_category_custom_column', 'change_category_description_output', 10, 3);

function change_category_description_output($string, $column_name, $term_id) {
    if ('description' === $column_name) {
        $term = get_term($term_id, 'category');
        $string = empty($term->description) ? 'No Description' : $term->description;
    }
    return $string;
}

Change the output of the description column for post tags

Change the output of the “Description” column for post tags to display “No Description” when it is empty:

add_filter('manage_post_tag_custom_column', 'change_post_tag_description_output', 10, 3);

function change_post_tag_description_output($string, $column_name, $term_id) {
    if ('description' === $column_name) {
        $term = get_term($term_id, 'post_tag');
        $string = empty($term->description) ? 'No Description' : $term->description;
    }
    return $string;
}

Add a custom column for a custom taxonomy

Add a custom column named “Custom” for a custom taxonomy called “location” and display the term’s ID:

add_filter('manage_location_custom_column', 'add_custom_location_column', 10, 3);

function add_custom_location_column($string, $column_name, $term_id) {
    if ('Custom' === $column_name) {
        $string = $term_id;
    }
    return $string;
}