I’ve got a CPT called Business Services and a custom taxonomy called Business Services. I want to display posts in my looper that are from the Business Services CPT or have been tagged with the Business Services taxonomy. I’ve tried creating multiple arrays for a var dump, but nothing seems to work.
This is my array
$query = array(
'post_type' => 'business_ser_dir_ltg',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => -1,
'orderby' => '{{dc:url:param key="orderby" fallback="rand"}}',
'order' => '{{dc:url:param key="order" fallback="dsc"}}',
'offset' => 0,
'category_name' => '{{dc:term:slug}}',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'secondary_listing_category',
'field' => 'slug',
'terms' => 'business-services',
'operator' => 'IN',
),
),
);
var_dump( http_build_query( $query ) );
This is query that was built, but does not work:
post_type=business_ser_dir_ltg&post_status=publish&ignore_sticky_posts=1&posts_per_page=-1&orderby={{dc:url:param key="orderby" fallback="rand"}}&order={{dc:url:param key="order" fallback="dsc"}}&offset=0&category_name={{dc:term:slug}}&tax_query%5Brelation%5D=AND&tax_query%5B0%5D%5Btaxonomy%5D=secondary_listing_category&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D=business-services&tax_query%5B0%5D%5Boperator%5D=IN
What do I need to change in my array to get the looper to display posts from my CPT and custom taxonomy?