3, 'cat' => esc_html(get_theme_mod('berkeley_featposts_cat')), 'ignore_sticky_posts' => true, ); $lastposts = new WP_Query($args); while ( $lastposts->have_posts() ) : $lastposts->the_post(); global $berkeley_fpost_ids; $berkeley_fpost_ids[] = get_the_id(); endwhile; wp_reset_postdata(); endif; add_action('pre_get_posts', 'berkeley_exclude_single_posts_home'); function berkeley_exclude_single_posts_home($query) { global $berkeley_fpost_ids; if ($query->is_home() && $query->is_main_query()) { $query->set('post__not_in', $berkeley_fpost_ids); } }