Check if term object is in array
WordPress has the wp_list_pluck function, which can be helpful here. We can make an array of just term IDs from the array of objects like: $term_ids = wp_list_pluck( $subcat_terms, ‘term_id’ ); Then we can check in_array: $this_id = 42; if( in_array( $this_id, $term_ids ) ){ // do something }