关于How to Display Post Excerpts in Admin by Default?, 我们如何完全删除屏幕选项下的摘录复选框以获得完整的解决方案?
如何删除屏幕选项下的摘录复选框
1 个回复
最合适的回答,由SO网友:Dedering 整理而成
您可以使用CSS实现这一点。
.metabox-prefs label[for="postexcerpt-hide"] {
display: none;
}
In regard to adding the CSS to the admin section, you have two options:
选项1:将CSS添加到样式表中,并使用admin_enqueue_scripts
钩function load_custom_wp_admin_style() {
wp_register_style( \'custom_wp_admin_css\', get_template_directory_uri() . \'/admin-style.css\', false, \'1.0.0\' );
wp_enqueue_style( \'custom_wp_admin_css\' );
}
add_action( \'admin_enqueue_scripts\', \'load_custom_wp_admin_style\' );
选项2:使用admin_head
钩function remove_post_excerpt_checkbox() {
?>
<style>
.metabox-prefs label[for="postexcerpt-hide"] {
display: none;
}
</style>
<?php
}
add_action( \'admin_head\', \'remove_post_excerpt_checkbox\' );
结束