0

I have a custom taxonomy. When I go to the page in the admin where it can be managed -

edit-tags.php?taxonomy=bundles&post_type=kea_activity

I see a table with headings for Name, Description, Slug, Count. I just don't want Count to appear:

enter image description here

I could just hide it with CSS but I would prefer to not show it with a filter. Is there any filter which can do this? I have searched everywhere and found nothing.

Update The problem evolved - as well as hiding a default column, I wanted to add a new one and populate it. The code below + my comment to @cjbj's answer is the solution to this problem.

This is what I now have:

public function taxonomy_bundles_column( $columns )
{
        unset($columns['posts']); //Count column
        $columns['foo'] = 'Foo';
        return $columns;
}
add_filter('manage_edit-bundles_columns' , array($this, 'taxonomy_bundles_column'));



public function taxonomy_bundles_column_content($string)
{
  
        return 'test';
}
add_action('manage_bundles_custom_column', array($this, 'taxonomy_bundles_column_content'));

My custom taxonomy is called 'bundles'. This is associated with a custom post type.

This is on the edit-tags screen. The one where you can add and edit terms to a taxonomy.

Now I am quite close. But the handler for the action hook only takes one parameter - which is always an empty string. So - all i can do is output the same value to each row. There must be a way to get more params - e.g. the term_id, so I can do something per term.

(I found a post, which is about the same problem, but the only proposed solution on that page does not in fact work).

The above produces this result:

enter image description here

1 Answer 1

1

The exact name of that filter depends on the name of the taxonomy. The general outline is “manage_{$this->screen->taxonomy}_custom_column”. You may have to include an extra test for the post type inside the filter function to prevent it from being applied to other post types that use the same taxonomy.

4
  • Thanks. But I still can't get it. The page on which the columns I want to manipulate is: edit-tags.php?taxonomy=bundles&post_type=kea_activity where 'bundles' is my custom taxonomy and 'kea-activity' is my custom post type. I have looked at the docs which you helpfully sent me and other posts. I now have 'manage_edit-tags_bundles_column' and all kinds of variations but i still can't get it to work. Maybe something to do with the custom post type?
    – Kropotkin
    Commented Apr 20 at 11:17
  • Without knowing your code it is impossible to guess what could be wrong with it
    – cjbj
    Commented Apr 20 at 16:50
  • I have updated my original post with the current state of play.
    – Kropotkin
    Commented Apr 20 at 17:04
  • 1
    Finally - got it. I need: add_filter('manage_bundles_custom_column', array($this, 'taxonomy_bundles_column_content'), 10, 3); - the 3 is key because this tells it to pass all 3 available arguments. A beginner's mistake I guess. Thanks @cjbj
    – Kropotkin
    Commented Apr 20 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.