Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Plugin Name: Exclude pages from admin
- Plugin URI: https://www.johnparris.com/
- Description: Removes pages from admin that shouldn't be edited.
- Version: 1.0
- Author: John Parris
- Author URI: https://www.johnparris.com/
- License: GPLv2
- */
- function jp_exclude_pages_from_admin($query) {
- $blogpage = get_page_by_title( 'Blog' );
- if ( ! is_admin() )
- return $query;
- global $pagenow, $post_type;
- if ( $pagenow == 'edit.php' && $post_type == 'page' )
- $query->query_vars['post__not_in'] = array($blogpage->ID); // Enter your page IDs here
- }
- add_filter( 'parse_query', 'jp_exclude_pages_from_admin' );
- // Remove the Edit link from the admin bar
- function jp_remove_admin_bar_edit_link() {
- if( is_page('blog')) {
- global $wp_admin_bar;
- $wp_admin_bar->remove_menu( 'edit' );
- }
- }
- add_action( 'wp_before_admin_bar_render', 'jp_remove_admin_bar_edit_link' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement