admin管理员组

文章数量:1336281

This may be a repeat but it's the combination of things I can't find.

Custom post type is event.

I have added an admin column 'Event Date' generated by ACF and it appears at the right. Everything appears fine in this order; 'Title', 'Venue', 'Date' 'Event Date'

I'd like to reorder it. So far so good, this code does that.

But the custom taxonomy 'venue' which has the slug venue does not reappear (it appears but is not populated). How do I find out what the custom taxonomy is called for the purposes of the admin columns?

function reorder_event_columns( $columns ) {

$columns = array(
    'cb' => $columns['cb'],
    'title' => __( 'Title' ),  // Post Title
    'venue' => __( 'Venue'), // not populated!
    'event_date' => __( 'Start Date'), // Appears fine
    'date' => __('Date'), // Published Date
);

  return $columns;
}

add_filter( 'manage_event_posts_columns', 'reorder_event_columns' );

This may be a repeat but it's the combination of things I can't find.

Custom post type is event.

I have added an admin column 'Event Date' generated by ACF and it appears at the right. Everything appears fine in this order; 'Title', 'Venue', 'Date' 'Event Date'

I'd like to reorder it. So far so good, this code does that.

But the custom taxonomy 'venue' which has the slug venue does not reappear (it appears but is not populated). How do I find out what the custom taxonomy is called for the purposes of the admin columns?

function reorder_event_columns( $columns ) {

$columns = array(
    'cb' => $columns['cb'],
    'title' => __( 'Title' ),  // Post Title
    'venue' => __( 'Venue'), // not populated!
    'event_date' => __( 'Start Date'), // Appears fine
    'date' => __('Date'), // Published Date
);

  return $columns;
}

add_filter( 'manage_event_posts_columns', 'reorder_event_columns' );
Share Improve this question asked May 23, 2020 at 7:34 Chris PinkChris Pink 7321 gold badge6 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

As ever, simple when you know.

Custom taxonomy columns in admin are called 'taxonomy-venue' if 'venue' is the taxonomy slug

So I now have my columns in the right order and even the custom taxonomy and acf sortable. Bliss.

本文标签: Reordering admin columns for CPT with custom taxonomy and an added custom field