Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hagronnestad/5195336 to your computer and use it in GitHub Desktop.

Select an option

Save hagronnestad/5195336 to your computer and use it in GitHub Desktop.
WordPress: Hide some pages from admin to disable editing
add_filter( 'parse_query', 'exclude_pages_from_admin' );
function exclude_pages_from_admin($query) {
global $pagenow, $post_type;
if (is_admin() && $pagenow=='edit.php' && $post_type =='page') {
$query->query_vars['post__not_in'] = array(2, 71);
}
}
@hagronnestad
Copy link
Author

It might still work, but I'm just chiming in to tell you that this snippet is very old by now. ๐Ÿ˜ƒ

@pgroot91
Copy link

pgroot91 commented Dec 4, 2019

https://www.isitwp.com/exclude-pages-from-edit-list-by-id/ another source that accomplish the same ๐Ÿ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment