Created
December 15, 2012 09:14
-
-
Save rianrietveld/4292303 to your computer and use it in GitHub Desktop.
Exclude by missing meta value in WordPress query is not logged in using the Members plugin
This file contains hidden or 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
add_filter( 'pre_get_posts', 'rrwd_filter_posts' ); | |
function rrwd_filter_posts( $query ) { | |
if( !is_user_logged_in() ) { | |
$meta_query = array( | |
array( | |
'key' => '_members_access_role', | |
'compare' => 'NOT EXISTS' | |
) | |
); | |
$query->set( 'meta_query', $meta_query ); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment