How to hide protected posts from archive?

Question

Im trying to hide protected posts in WP from loop:

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

works fine, but except archive. For eg. I have one post in June. In calendar widget I still can see that is post at this date, but when I get there, then I get 404.

0
Damian P. 4 months 0 Answers 23 views 0

Leave an answer