Thanks brasofilo!
add_action( 'pre_get_posts', 'hide_pages_to_user_except_admins' );
function hide_pages_to_user_except_admins( $query ) {
if( !is_admin() )
return $query;
global $pagenow;
$pages = array('201','38','99'); //page ids
if(
'edit.php' == $pagenow
&& ( get_query_var('post_type') && 'page' == get_query_var('post_type') )
)
$query->set( 'post__not_in', $pages );
return $query;
}
Related Posts:
- Can an admin check passwords of registered users?
- How to display only logged in user’s post comments in comments area
- Redirect admin 403 “Cheatin uh?” admin pages
- You do not have permission to access this document on form submit
- What are the standard admin CSS id/class tags?
- Modal window from within WordPress admin
- How to Change the Default Home Page for the WordPress Dashboard?
- How To Remove WordPress Version From The Admin Footer
- Set Default Admin Colour For All Users
- Securing Admin Accounts – Username Discovery
- How-to make the admin area mobile friendly [closed]
- How to obtain the user ID of the current profile being edited in WP-Admin?
- 3.3: How do you hide the new dashboard welcome panel?
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- Read only capability for custom post in admin area
- Appearance->Editor not visible
- Possible to create placeholder images in WordPress editor that are clickable (should bring up uploader)?
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Admin pages have no content
- Blocking Administrative Access to Authors and Subcribers?
- How to find out if an wp-admin action edited a file?
- WordPress 3.8 get current admin color scheme
- How to Use Resposive Tables in WordPress ADMIN Pages?
- How can I access profile Admin Colour Scheme
- I keep getting logged out in Firefox
- Add tabbed menu to admin page
- remove_action with profile_personal_options
- Getting the different post statuses + count like in edit.php, in a custom submenu page
- how to redirect to url.com/wp-admin if url.com/admin is typed in?
- Restrict dashboard access for specific user roles to specific actions
- How To Create User Specific Admin User Pages?
- Change the Default Pages Menu View in wp-admin
- How can I restore admin capabilities?
- Protect custom php file with login
- Conditionally load CSS/JS/PHP in wp-admin if using a mobile device
- How to disable automatic excerpt generation *in admin*?
- Limit Words in Category / Term Description – Admin Panel
- Change top level menu item to point to custom submenu item
- Associating custom submenu item with post type of top level menu item
- What determines whether admin toolbar is shown to a logged-in user?
- Adding text in more than one language (at the same time)
- wp-admin post.php JavaScript Links Not Working
- front end editing using iFrames, best approach?
- Super slow admin panel
- Admin Taxonomy Terms – Orderby Term Field
- How do I add an admin notice within javascript in the admin interface for posts?
- Fatal error: Exception thrown without a stack frame in Unknown on line 0
- Hide Pages on Edit Pages based on Capability (edit_others_pages)?
- How do you set up a WordPress blog with multiple authors to allow something like StackExchange’s “community wiki” feature?
- Admin cannot publish
- How to hide a specific part of dashboard for non-admin roles?
- Unable to Access WP Admin or Login buttons after Migration
- Add ‘Last Modified’ and Attachments (Yes/No) to WordPress Users Column
- Editors change a permalink on an unpublished post, but only admins change a permalink on a post that has ever been published?
- How Can I Found Admin Directory
- WordPress post feature image not uploading
- Combine and Minify wp-admin files, also re-write URI’s for CDN
- WordPress administrator area access disabled temporarily due to widespread brute force attacks
- WordPress Remove Submenus
- 500 internal server error on wp-admin only
- Redirect from the dashboard to edit.php if wp_is_mobile() is true
- Seems that admin_post_{action} does not executing
- Add Custom Script in Other Plugin’s Options page
- When submitting the form site.com/blog/wp-admin it goes to site.com/wp-admin
- Create a WordPress administrator without access to back-end
- Can I host WP-admin locally for a remote blog?
- get_current_screen and the WP_Screen class
- Is there alternative to WP_List_Table?
- WordPress Brute Force Prevention
- Admin login not working
- Access for adding subpages but not for pages
- Adding and removing columns from the admin pages panel
- current_user_can(‘administrator’) not working in custom login
- How to make sure your admin doesn’t hi-jack you site?
- How to change the descriptive text on the menus admin page?
- Dynamic WordPress Admin Panel
- “sufficient permissions” error for admin after duplicating WP database to new install
- Wp-Admin FTPS Connection Error unlike Filezilla
- Give admin_menu permission to specific users
- How To Remove Import/Export Option From Tools?
- Doesn’t call user information to include “wp-load.php” in an external php file
- Cannot access wp-admin after installing SSL – user capabilities not being set
- Redirect non-admin after login, and in url – /admin
- How can I create multiple different admin roles with their own capabilities
- Localhost install: Administrator lost administrator access; cannot access Dashboard
- Signed-in as admin on just part of the site
- How to update my website with WordPress?
- wordpress login loop after install
- Unable to render Admin Notices
- WordPress login not working
- Admin blank but Admin menu showing
- Problems in migration of WordPress site from local server to the online server
- WYSIWYG editor not in a post editor?
- htaccess and htpasswd
- plugin to upload to youtube via wordpress [closed]
- I don’t have permission to save the theme options I created myself?
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
- how to know if admin is in edit page or post [duplicate]
- How to disable https from wordpress site?
- Remove iPhone detection on login page