custom post types - How can i add multiple variable to a !== query

admin2025-06-02  1

i'm trying to add a taxonomy filter on multiple CPT linked to this taxonomy.

i'm good for 1 cpt at a time, but i'm definitly sure i can do much easyier with one function for all cpt.

actually i have cpt "region", and i wish to add more like "region2", "region3", how can i do this ?

my code :

if ( 'region' !== $post_type )
// xxx
endif;

i'm trying to add a taxonomy filter on multiple CPT linked to this taxonomy.

i'm good for 1 cpt at a time, but i'm definitly sure i can do much easyier with one function for all cpt.

actually i have cpt "region", and i wish to add more like "region2", "region3", how can i do this ?

my code :

if ( 'region' !== $post_type )
// xxx
endif;
Share Improve this question asked Mar 6, 2019 at 16:16 GregoryGregory 6025 silver badges20 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You could for example use in_array. Like so,

if ( ! in_array( $post_type, array( 'region', 'region2', 'region3' ) ) ) {
// something
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748836364a314127.html

最新回复(0)