title: Wordpress loop to filter out by meta
body: <p>This kind of follows on from a previous question where JanW : <a href="http://bit.ly/VQy9hb" rel="nofollow">http://bit.ly/VQy9hb</a></p>
  
  <p>I'm trying to hide posts that contain certain meta data, in this case meta_name = "smartPrivate".</p>
  
  <p>The function below works but unfortunately also affects the menu loop (it just disappears).</p>
  
  <p>Does anyone know how I can hide these posts from appearing in all loops but not affect the menu (and who knows what else...)</p>
  
  <p>Thanks in advance
  Rob</p>
  
  <pre><code>function hide_some_posts( $query ) {
  
      if (!is_user_logged_in()) {
  
          $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>