如何在日期列之前显示自定义帖子类型列

时间:2017-12-07 13:09:11

标签: php wordpress

我使用以下代码输出与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');

结果是这样,首先是日期,第二列是第二列。如何修改我的代码以首先显示所有自定义列,并将日期列显示在最后? enter image description here

1 个答案:

答案 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');

希望这个有所帮助。