Add exception to this query based on post id

Hi there fist time on this forum!
I would like to manually “exclude” some specific id’s from this query:

function get_pattern_products() {
	
	$collections = [98, 123, 128, 145, 146, 147];
	if (!in_array(get_queried_object()->parent, $collections)) {
		return;	
	}

	$term_id = get_queried_object()->term_id;	
  $args = array(
    'post_type' => 'products_new',
    'tax_query' => array(
      array(
        'taxonomy' => 'collection',
        'field' => 'id',
        'terms' => $term_id
        ),
    ),
  );
  $posts = new WP_Query($args);
  $posts = $posts->get_posts();

	$html = '
'; foreach($posts as $post) { $id = $post->ID; $html .= ''; $html .= '
'; $html .= '
'; $html .= '
' . get_the_title($id) . '
'; $html .= '

Available sizes

' . get_field('available_sizes', $id) . '

'; $html .= '
'; $html .= '
'; } $html .= '
'; return $html; } add_shortcode('get_pattern_products', 'get_pattern_products');

Add post__not_in to your $args.

Sponsor our Newsletter | Privacy Policy | Terms of Service