title: hide wordpress posts and categories for not logged in users
body: <p>Basically I handled this issue by overriding parent theme files in child theme.
  i.e., by using </p>
  
  <pre><code>if( is_user_logged_in() ){
     ...................
     wordpress loop
  }
  </code></pre>
  
  <p>I had to do this for every template ( wherever there is wordpress loop )</p>
  
  <p>Though I didn't have to do this for displaying sidebars as if there was category in widget and whenever user clicks on it to view it, it would automatically say you don't have proper privileges to view this content.</p>
  
  <p>So, my question is, is there any better way to hide wordpress content ( this may be anything, like normal posts, custom post types,.. ) from just visitors.</p>
  
  <pre><code>function bt_hide_from_guestes( $content ) {
      global $post;
  
      if ( $post-&gt;post_type == 'post' ) {
          if ( !is_user_logged_in() ) {
              $content = 'Please login to view this post';
          }
      }
  
      return $content;
      }
  
  add_filter( 'the_content', 'bt_hide_from_guestes' );
  </code></pre>
  
  <p>Above code didn't help</p>