我使用以下代码输出与CPT相关的列:
//set up new column to show custom meta theme_color
function pr_testimonials_column($column) {
$column['testimonial_person_tagline'] = 'Person Tagline';
return $column;
}
add_filter('manage_testimonials_posts_columns', 'pr_testimonials_column');
//show custom column data
function pr_show_testimonials_column($name) {
global $post;
switch ($name) {
case 'testimonial_person_tagline':
$testimonial_person_tagline = get_post_meta($post->ID, '_testimonial_person_tagline', true);
echo $testimonial_person_tagline;
}
}
add_action('manage_testimonials_posts_custom_column', 'pr_show_testimonials_column');
答案 0 :(得分:1)
找到Date列的键,下一步取消设置,然后在添加自定义列后设置,
function pr_testimonials_column($column) {
// Remove Date
unset($column['date']);
$column['testimonial_person_tagline'] = 'Person Tagline';
$column['date'] = 'Date';
return $column;
}
add_filter('manage_testimonials_posts_columns', 'pr_testimonials_column');
希望这个有所帮助。