简体   繁体   中英

How to show custom post type column before date column

I am using the following code to output columns pertaining to a 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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