Wordpress Logo

CPT: Taxonomie Query

<!-- Query a specific taxonomy term -->
  
<?php
    $args = array(
    'posts_per_page' => 4,
    'post_type' => 'recipes',
    'orderby' => 'rand',
    'tax_query' => array(
        array(
        'taxonomy' => 'course',
        'field'    => 'slug',
        'terms'    => 'main-dishes',
        )
    ),
    );
    $query = new WP_Query( $args );
    while($query->have_posts()): $query->the_post();
    the_title('<h1>', '</h1>');
    endwhile; wp_reset_postdata();
    ?>