 <p>So your problem is that it affects other queries than the main query, if I understand your situation correctly. This is pretty much why <a href="http://codex.wordpress.org/Function_Reference/is_main_query" rel="nofollow">is_main_query</a> exists. So try this:</p> <pre><code>function hide_some_posts( $query ) { if (!is_user_logged_in() &amp;&amp; $query-&gt;is_main_query() ) { $query-&gt;set( 'meta_query', array( array( 'key' =&gt; 'smartPrivate', 'value' =&gt; 'smartPrivate_loggedIn', 'compare' =&gt; '!=' ), array( 'key' =&gt; 'smartPrivate', 'value' =&gt; 'smartPrivate_loggedInMentors', 'compare' =&gt; '!=' ) )); } return $query; } add_filter( 'pre_get_posts', 'hide_some_posts' ); </code></pre>