Skip to content

Instantly share code, notes, and snippets.

@thefrosty
Last active December 10, 2015 17:08
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 thefrosty/4465516 to your computer and use it in GitHub Desktop.
Save thefrosty/4465516 to your computer and use it in GitHub Desktop.
function extendd_exclude_extendd_settings_plugin( $query ) {
if ( 'plugin' == $query->query['post_type'] ) {
$current_user = wp_get_current_user();
// Not logged in = $current_user->ID == 0
if ( 0 == $current_user->ID ) /* && ( false === $query->query_vars['suppress_filters'] ) */ ) {
$protected_posts = get_extendd_settings_plugin(); //returns integer
if ( !empty( $protected_posts ) ) {
$query->query_vars['post__not_in'] = array( $protected_posts );
}
}
}
return $query;
}
add_action( 'pre_get_posts', 'extendd_exclude_extendd_settings_plugin' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment