As I stated in comments, you need pre_get_posts
and a meta_query
to exclude posts from a certain custom field with a certain value from the main query. It is really in your best interest to read up on the before mentioned. Just remember, all parameters in WP_Query
works on pre_get_posts
as WP_Query
uses pre_get_posts
to alter the query parameters, and the main query uses WP_Query
In short, you can try the following: (REQUIRES PHP 5.4+ and the code is untested)
add_action( 'pre_get_posts', function ( $q )
{
if ( !is_admin() // Targets the front end only, we don't need this for is_home()
&& $q->is_home() // Change this to the appropriate page, here we only target the home page
&& $q->is_main_query() // Target the main query only
) {
$meta_query = [
[
'key' => 'Custom_ID',
'compare' => 'NOT IN' // Do not get posts from this spoecific key/value pair
]
];
$q->set( 'meta_query', $meta_query );
}
});
pre_get_posts
with ameta_query
. There are many examples on site, just use the site search. :-)