列に行を追加
functions.php
function add_custom_column( $defaults ) {
$defaults['event_cat'] = 'カテゴリー';
return $defaults;
}
add_filter('manage_event_posts_columns', 'add_custom_column');
'event' : 投稿タイプ
'event_cat' : タクソノミー名
追加した行にタームを追加
functions.php
function add_custom_column_id($column_name, $id) {
if( $column_name == 'event_cat' ) {
echo get_the_term_list($id, 'event_cat', '', ', ');
}
}
add_action('manage_event_posts_custom_column', 'add_custom_column_id', 10, 2);
列の順番を変更
functions.php
function sort_custom_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'タイトル',
'region' => 'カテゴリー',
'date' => '日付'
);
return $columns;
}
add_filter( 'manage_event_posts_columns', 'sort_custom_columns' );
アイキャッチを表示
functions.php
function add_custom_column( $defaults ) {
$defaults['thumbnail'] = 'サムネイル';
$defaults['event_cat'] = 'カテゴリー';
return $defaults;
}
add_filter('manage_event_posts_columns', 'add_custom_column');
function add_custom_column_id($column_name, $id) {
if( $column_name == 'event_cat' ) {
echo get_the_term_list($id, 'event_cat', '', ', ');
}
if ( 'thumbnail' == $column_name ) {
$thumb = get_the_post_thumbnail($post_id, array(80,80), 'thumbnail');
echo ( $thumb ) ? $thumb : '?';
}
}
add_action('manage_event_posts_custom_column', 'add_custom_column_id', 10, 2);
function sort_custom_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'タイトル',
'thumbnail' => 'サムネイル',
'region' => 'カテゴリー',
'date' => '日付'
);
return $columns;
}
add_filter( 'manage_event_posts_columns', 'sort_custom_columns' );