Hiding Pages on Dashboard

  • 0
  •  0

You may need to hide some pages in wp-admin from specific admin, editor or author. Easily you can do this with following snippet.

add_filter( 'parse_query', 'ops_hide_pages_in_dashboard' );
public function ts_hide_pages_in_wp_admin($query){
      global $pagenow,$post_type;
      $user = wp_get_current_user();
      // hide following pages from wp-admin users except administrator
      if (is_admin() && $pagenow=='edit.php' && $post_type =='page' && !in_array('administrator', (array) $user->roles)) {
            $query->query_vars['post__not_in'] = [23, 24]; // Ids of page
        }
}

No Comments

    Leave A Comment