在本例中,您可以轻松设置要隐藏发布选项的帖子类型,本例将隐藏内置pots类型的发布选项page
和自定义帖子类型cpt_portfolio
.
/**
* Hides with CSS the publishing options for the types page and cpt_portfolio
*/
function wpse_36118_hide_minor_publishing() {
$screen = get_current_screen();
if( in_array( $screen->id, array( \'page\', \'cpt_portfolio\' ) ) ) {
echo \'<style>#minor-publishing { display: none; }</style>\';
}
}
// Hook to admin_head for the CSS to be applied earlier
add_action( \'admin_head\', \'wpse_36118_hide_minor_publishing\' );
重要更新我还建议您强制发布状态为;“已发布”;要避免将帖子保存为草稿,请执行以下操作:
/**
* Sets the post status to published
*/
function wpse_36118_force_published( $post ) {
if( \'trash\' !== $post[ \'post_status\' ] ) { /* We still want to use the trash */
if( in_array( $post[ \'post_type\' ], array( \'page\', \'cpt_portfolio\' ) ) ) {
$post[\'post_status\'] = \'publish\';
}
return $post;
}
}
// Hook to wp_insert_post_data
add_filter( \'wp_insert_post_data\', \'wpse_36118_force_published\' );