Created
January 22, 2015 06:36
-
-
Save yoren/e56f6963cc2a40f92eb9 to your computer and use it in GitHub Desktop.
Intercepting posts in WP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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