简体   繁体   English

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

[英]How to show custom post type column before date column

I am using the following code to output columns pertaining to a CPT: 我正在使用以下代码输出与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');

The result is this, with the date first and the columns second. 结果是这样,日期在第一位,列在第二位。 How can I modify my code to show all of my custom columns first, and date column last? 如何修改代码以首先显示所有自定义列,最后显示日期列? 在此处输入图片说明

Find the key for the Date column, next step to unset it and then set after adding your custom column, 找到“日期”列的键,下一步将其取消设置,然后在添加自定义列后进行设置,

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

Hope this one helps. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM