Columns
You can now modify Taxonomy
columns using the same methods as you would for a PostType
. For example:
Add Columns
To add columns to the admin edit screen pass an array of column slugs and labels to the add()
method.
Hide Columns
To hide columns pass the column slug to the hide()
method. For multiple columns pass an array of column slugs.
Column Order
To rearrange columns pass an array of column slugs and position to the order()
method. Only columns you want to reorder need to be set, not all columns. Positions are based on a zero based index.
Set Columns
To set all columns to display pass an array of the column slugs and labels to the set()
method. This overrides any other configuration set by the methods above.
Populate Columns
To populate any column use the populate()
method, by passing the column slug and a callback function.
Taxonomy columns work differently to post type columns. The callback receives 3 arguments, the columns content, the column name and the term ID. Also, the hook used is a filter, so the column value must be returned.
Sortable Columns
To define which custom columns are sortable use the sortable()
method. This method accepts an array of column slugs and an array of sorting options.
The first option is the term meta_key
to sort the columns by.
The second option is how the items are ordered, either numerically (true
) or alphabetically (false
) by default.
Last updated