MemberPress: Exclude Protected Posts From the Main Query

function mepr_exclude_protected_posts_from_query_block( $query ) { if (! is_admin() && $query->is_main_query()) { $posts_to_exclude = array(); $posts = get_posts(array(‘post_type’ => ‘post’, ‘posts_per_page’ => -1)); foreach ($posts as $post) { if (MeprRule::is_locked($post)) { $posts_to_exclude[] = $post->ID; } } if (! empty($posts_to_exclude)) { $query->set(‘post__not_in’,…Continue reading