To hide Password Protected posts from the ‘loop’

This goes into functions.php

function twstudio_password_post_filter( $where = '' ) {
if (!is_single() && !is_admin()) {
$where .= " AND post_password = ''";
}
return $where;
}
add_filter( 'posts_where', 'twstudio_password_post_filter' );

Leave a Reply

Your email address will not be published. Required fields are marked *