I have a pre_get_posts filter to show exclude some posts on the homepage. But I can’t exclude the posts which are closed for commenting. How do I do this?
What I have is:
function wp_filter_pre_get_posts( $query ) {
// Only modify when on homepage & only the main query
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'comment_status', 'open' );
$query->set( 'tag__not_in', '188' );
$query->set( 'posts_per_page', '3' );
}
}
add_filter( 'pre_get_posts', 'wp_filter_pre_get_posts' );
Excluding the post from category 188 works fine, but excluding the posts with closed comments does not. Any hints?