Skip to content

Instantly share code, notes, and snippets.

@yoren
Created January 22, 2015 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoren/e56f6963cc2a40f92eb9 to your computer and use it in GitHub Desktop.
Save yoren/e56f6963cc2a40f92eb9 to your computer and use it in GitHub Desktop.
Intercepting posts in WP
<?php
function my_pre_get_posts( $query ) {
if ( ! is_user_logged_in() ) {
$query->set( 'post_type', '404' ); // Do something that you'll never get results
return;
}
}
add_action( 'pre_get_posts', 'my_pre_get_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment