Edited to reflect question in OP’s comment.
The contents of the tax_query
array are not exactly right: as you’re querying by slug, the field
parameter of the individual taxonomy query should be "slug"
.
You’re currently basically querying for all service
posts from all service categories (well, not even that, because get_terms
returns objects, but still).
To query for a single (or more than one) specific terms from which to load posts, specify the terms in the terms
array. tax_query
is then parsed accordingly.
$services_post = new WP_Query( array(
'post_type' => 'service',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'service_cat',
'field' => 'slug',
'terms' => array( 'cat1' ) // Array of service categories you wish to retrieve posts from
)
)
) );
By the way, I am assuming you want to retrieve all posts of post type service