Exclude password protected posts from WordPress loop

// Filter to hide protected posts
function exclude_protected($where) {
    global $wpdb;
    return $where .= " AND {$wpdb->posts}.post_password = '' ";
}

// Decide where to display them
function exclude_protected_action($query) {
    if( !is_single() && !is_page() && !is_admin() ) {
        add_filter( 'posts_where', 'exclude_protected' );
    }
}

// Action to queue the filter at the right time
add_action('pre_get_posts', 'exclude_protected_action');

Simply copy above code and paste at the end of functions.php file and refresh your loop posts pages
Amazing you have removed password protected posts from loop list.

But remember one thing when using this code in functions.php it excludes all password protected posts from all another WordPress loops in the project.
0 Points