在后台页面管理列表中隐藏特定的页面
对于WordPress多用户站点,隐藏一些比较重要的信息是很有必要的。有的时候,我们通过页面(Page)建立了一些很重要的功能页面,比如一些投稿页面、用户信息页面、前台布局页面等,我们当然不希望被其他用户看到这些页面。
你可以在主题的 functions.php 中添加下面的代码:
add_action( 'pre_get_posts' ,'exclude_this_page' );
function exclude_this_page( $query ) {
if( !is_admin() )
return $query;
global $pagenow;
if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
$query->set( 'post__not_in', array(23,28,30) ); // 页面的ID
return $query;
}
来自https://www.wpdaxue.com/exclude-pages-from-admin-edit-pages-list.html
