Skip to content

Instantly share code, notes, and snippets.

@yllus
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save yllus/2f18709aa9371f17e9f9 to your computer and use it in GitHub Desktop.

Select an option

Save yllus/2f18709aa9371f17e9f9 to your computer and use it in GitHub Desktop.
// Disable WordPress's home page query (as much as we can).
function home_page_query_disable( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
if ( $query->is_home ) {
// Add a filter that effectively returns no results ever.
add_filter('posts_where', 'disable_query_filter');
}
}
return $query;
}
add_action('pre_get_posts', 'disable_query_filter');
// The WHERE search filter for disabling the default home page query.
function disable_query_filter( $where = '' ) {
$where = " AND 0 = 1";
return $where;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment