admin管理员组

文章数量:1129020

In my custom post type I unset the title column to add onclick event on each post title but it shift's the check boxes to next column, how can I have back check boxes to the title or if I want to hide completely how can I do that.

First i remove all row actions

add_filter('post_row_actions', 'remove_row_actions', 10, 1);

function remove_row_actions($actions) {

    if (get_post_type() === 'tasks') {
        unset($actions['edit']);
        unset($actions['view']);
        unset($actions['trash']);
        unset($actions['inline hide-if-no-js']);
    }

    return $actions;

}

then I unset and re produce the title column

add_filter('manage_edit-tasks_columns', 'edit_first_column');

function edit_first_column($columns) {

    unset($columns['title']);

    $arr = array();

    foreach ($columns as $key => $value) {
        $arr['new_title'] = 'Title';
        $arr[$key] = $value;
    }

    return $arr;

}

In my custom post type I unset the title column to add onclick event on each post title but it shift's the check boxes to next column, how can I have back check boxes to the title or if I want to hide completely how can I do that.

http://prntscr.com/gv5odl

First i remove all row actions

add_filter('post_row_actions', 'remove_row_actions', 10, 1);

function remove_row_actions($actions) {

    if (get_post_type() === 'tasks') {
        unset($actions['edit']);
        unset($actions['view']);
        unset($actions['trash']);
        unset($actions['inline hide-if-no-js']);
    }

    return $actions;

}

then I unset and re produce the title column

add_filter('manage_edit-tasks_columns', 'edit_first_column');

function edit_first_column($columns) {

    unset($columns['title']);

    $arr = array();

    foreach ($columns as $key => $value) {
        $arr['new_title'] = 'Title';
        $arr[$key] = $value;
    }

    return $arr;

}
Share Improve this question edited Oct 9, 2017 at 16:48 mmm 3,8083 gold badges16 silver badges22 bronze badges asked Oct 9, 2017 at 12:47 mohsinmohsin 1772 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

look what is in $columns, you will see the column cb for "checkbox"

then you can do that :

function edit_first_column($columns) {

    $arr = [
        "cb" => $columns["cb"];
        "new_title" = "Title";
    ]


    unset($columns['cb']);
    unset($columns['title']);

    $arr += $columns;

    return $arr;

}

本文标签: plugin developmentHow to enable or disable check boxes in custom post type