Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Created February 17, 2015 03:41
Show Gist options
  • Select an option

  • Save designbuildtest/cb48bf5b32d362baaf46 to your computer and use it in GitHub Desktop.

Select an option

Save designbuildtest/cb48bf5b32d362baaf46 to your computer and use it in GitHub Desktop.
Exclude Homepage from main Admin query
function exclude_this_page( $query ) {
if( ! is_admin() )
return $query;
global $pagenow;
if( 'edit.php' == $pagenow && ( get_query_var( 'post_type' ) && 'page' == get_query_var( 'post_type' ) ) )
$query->set( 'post__not_in', array(2) ); // Change '2' to the ID of your Homepage
return $query;
}
add_action( 'pre_get_posts' ,'exclude_this_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment