is_tax doesn’t work with multiple taxonomies, How to fix?
-
I use that code to sort posts in archives by date from Advanced Custom Fields. For example, this code sorts posts from my custom taxonomy “genre”:
function ptc_customize_wp_query( $query ) {
if ( $query->is_tax( 'genre', ) ) {
// Sort posts by project start date.
$query->set( 'order', 'DESC' );
$query->set( 'orderby', 'meta_value_num' );
// ACF date field value is stored like 20220328 (YYYYMMDD).
$query->set( 'meta_key', 'release-date' );
}
}But when I try to add additional taxonomies, they just do not work, works only the first one.
if ( $query->is_tax( 'genre', 'publisher', 'developer' ) ) {
The code above doesn’t work for ‘publisher’ and ‘developer’ taxonomies. But I want that it to work with multiple taxonomies. How to achieve this?
- The topic ‘is_tax doesn’t work with multiple taxonomies, How to fix?’ is closed to new replies.