How to Get All Posts but the Private ones?

I believe get_posts returns all published (no-private posts) but does display password protected posts. In fact, by default, the standard WP_Query loop does this as well. So by default, private posts shouldn’t appear.

If you wanted to display private posts for those logged in, and not those who are logged out, you could use the permissions parameter perm=>'readable'

$wp_query = new WP_Query( array( 'perm'=>'readable' ) );

This returns any posts the current user has permission to read. If they are logged out, then they only have permission to read published, non-private posts. Only those logged in, with the ability to read private posts will see the private posts.

Note

Password protected posts will still appear, but will obviously require a password to read the posts.

Leave a Comment