'taxonomies' => ['category'],
<div class="genre-block">
<div class="title">Жанры</div>
<ul class="genre__container">
<?php wp_list_categories('child_of=6&hide_empty=0&title_li=0'); ?>
</ul>
</div>
$default = array(
'post_type' => 'books',
'post_status' => 'publish',
'posts_per_page' => 12,
'tax_query' => [
'relation' => 'AND',
],
);
if ( ! empty($_GET['books_cat'])) {
$books_cat_arr = [];
foreach ($_GET['books_cat'] as $key => $elem) {
$books_cat_arr[] = $key;
}
$default['tax_query'][] = [
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $books_cat_arr,
];
}
}
$query = new WP_Query( $default );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
get_template_part( 'template-parts/content', 'new-buildings-list' );
$count_buildings = $query->found_posts;
}
} else {
get_template_part( 'template-parts/content', 'none' );
}
wp_reset_postdata();
get_terms()
$terms = get_terms( [
'taxonomy' => 'genres',
'hide_empty' => false,
] );
if ( $terms ) {
echo '<ul class="genres-list">';
foreach ( $terms as $key => $term ) {
echo '<li><a href="' . get_term_link( $term->term_id, $term->taxonomy ) . '">' . $term->name . '</a></li>';
}
echo '</ul>';
}
if ( is_post_type_archive( 'book' ) ) {
// ...
}