好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

移除WordPress后台显示选项的2种方法 - WordPress

移除WordPress后台显示选项的2种方法

有时我们看到后台的显示选项并不需要他要怎么隐藏呢?下面一聚教程小编为你提供了两种解决方法,希望对你会有所帮助。

方法一:现在我们看看小技巧如何利用代码把一些不必要的选项移除掉,代码如下:

<?php  function  remove_meta_boxes() {  # Removes meta from Posts #      remove_meta_box(‘postcustom’, 'post’,' normal’);      remove_meta_box(‘trackbacksdiv’, 'post’,' normal’);      remove_meta_box(‘commentstatusdiv’, 'post’,' normal’);      remove_meta_box(‘commentsdiv’, 'post’,' normal’);  # Removes meta from pages #      remove_meta_box(‘postcustom’, 'page’,' normal’);      remove_meta_box(‘trackbacksdiv’, 'page’,' normal’);      remove_meta_box(‘commentstatusdiv’, 'page’,' normal’);      remove_meta_box(‘commentsdiv’, 'page’,' normal’);      }      add_action(‘admin_init’,'remove_meta_boxes’);  ?> 

将这段代码放到 functions.php 文件中,然后再查看一下文章编辑页面右上角的显示选项,看看是不是有些选项被去掉了?

方法二:隐藏显示选项,在主题的functions.php中写如下代码:

function  remove_screen_options(){  return  false;}  add_filter( 'screen_options_show_screen' ,  'remove_screen_options' ); 

对Editor(编辑)以下级别的用户隐藏显示选项,代码如下:

function  remove_screen_options(){       if ( !current_user_can( 'publish_pages' ) )            return  false;       return  true;  }  add_filter( 'screen_options_show_screen' ,  'remove_screen_options' ); 

隐藏帮助选项卡,在主题的functions.php中添加如下代码:

add_filter(  'contextual_help' ,  'wpse50723_remove_help' , 999, 3 );  function  wpse50723_remove_help( $old_help ,  $screen_id ,  $screen ){       $screen ->remove_help_tabs();       return   $old_help ;  } 

查看更多关于移除WordPress后台显示选项的2种方法 - WordPress的详细内容...

  阅读:64次