admin管理员组

文章数量:1122846

I am trying to unset/hide some options in dashboard.

I am trying it for products screen.

Here is the screenshot

Here is the code i tried to hide SKU

/** Hide Dashboard widget by default via Screen Options */
add_filter( 'default_hidden_meta_boxes', 'wpfa_default_screen_option' );

function wpfa_default_screen_option( $hidden ) {
/** Add WP First Aid meta box ID to default hidden Screen Options array */
$hidden[] = 'sku-hide';

return $hidden;
}

Though it didn't work at all.

I need to hide these three items in screenshot.

Any Help will be appreciated.

I am trying to unset/hide some options in dashboard.

I am trying it for products screen.

Here is the screenshot

Here is the code i tried to hide SKU

/** Hide Dashboard widget by default via Screen Options */
add_filter( 'default_hidden_meta_boxes', 'wpfa_default_screen_option' );

function wpfa_default_screen_option( $hidden ) {
/** Add WP First Aid meta box ID to default hidden Screen Options array */
$hidden[] = 'sku-hide';

return $hidden;
}

Though it didn't work at all.

I need to hide these three items in screenshot.

Any Help will be appreciated.

Share Improve this question asked Jul 27, 2018 at 12:46 Nimesh DeoNimesh Deo 711 gold badge1 silver badge7 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

The best option would be to use CSS to hide these columns and fields.

Add this in your admin.css file to hide the SKU column

table.wp-list-table .column-sku {
    width: 10%
}

To hide options in Screen Options add the following CSS in admin.css

.metabox-prefs label:nth-child(2), .metabox-prefs label:nth-child(11), .metabox-prefs label:nth-child(12)  {
        display: none;
}

FYI to double check my nth-child CSS as it may not be exact. Play around with your admin.css file while inspecting the element in the wp-admin backend.

The best option to hide columns on the WordPress admin page is using the hidden_columns hook.

Example:

add_filter( 'hidden_columns', 'hide_meta_box', 10, 2 );
function hide_meta_box($hidden, $screen) {
        if ( $screen->post_type == 'your_post_type' ) {
            $hidden[] ='your_column_to_hidden';
        }
        return $hidden;
}

This code will hide the column your_column_to_hidden, but the user can display it.

本文标签: functionsHide some items from Screen options in dashboard for products