microtag
1/18/2018 - 11:24 AM

Excludi pagine da Wordpress admin menu

Mi server per excludere alcune pagine dal menu di wordpress. https://www.johnparris.com/how-to-hide-pages-in-the-wordpress-admin/

function jp_exclude_pages_from_admin($query) {

$exclude1 = get_page_by_path('privacy'); 
$exclude1 = get_page_by_path('menu'); 
  
  if ( ! is_admin() )
    return $query;
 
  global $pagenow, $post_type;
 
  if ( !current_user_can( 'administrator' ) && $pagenow == 'edit.php' && $post_type == 'page' )
    $query->query_vars['post__not_in'] = array( $exclude1->ID, $exclude2->ID ); // Enter your page IDs here
  
}
add_filter( 'parse_query', 'jp_exclude_pages_from_admin' );