Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
3 of 3 deleted 162 characters in body

Query custom post type by custom taxonomy (category slug)

I've followed several related solution. But I'm still facing the problem. I've applied the following code for my custom post query by taxonomy (category). But it's not working. I think my problem with 'terms'.

$terms = get_terms('service_cat');
$services_post = new WP_Query(array(
    'post_type'         => 'service',
    'posts_per_page'    => -1,
    'tax_query' => array(
        array(
            'taxonomy' => 'service_cat',
            'field' => 'cat1',
            'terms' => $terms
        )
    ),
));

I also tried by the following code

$services_post = new WP_Query(array(
            'post_type'         => 'service',
            'posts_per_page'    => -1,
            'category_name'     => 'cat1' 
))