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 badges2 Answers
Reset to default 0The 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
版权声明:本文标题:functions - Hide some items from Screen options in dashboard for products 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736284462a1927254.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论