I am trying to filter a CPT to display fields by Taxonomy, I am currently using the following code:-
$args = array(
'posts_per_page'=> -1,
'post_type' => 'episode',
'order' => 'DESC',
//'meta_key' => $filter_key,
//'meta_value' => $filter,
'tax_query' => array(
array(
'taxonomy' => 'name',
'field' => 'make',
'terms' => array('Jaguar')
)
),
);
However, this is not returning any results.
This is what I am trying to filter:-
array(3) { [0]=> object(WP_Term)#7336 (10) { ["term_id"]=> int(25) ["name"]=> string(6) "Jaguar" ["slug"]=> string(6) "jaguar" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(25) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(0) ["filter"]=> string(3) "raw" } [1]=> object(WP_Term)#7493 (10) { ["term_id"]=> int(24) ["name"]=> string(13) "Mercedes K100" ["slug"]=> string(13) "mercedes-k100" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(24) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(0) ["filter"]=> string(3) "raw" } [2]=> object(WP_Term)#7492 (10) { ["term_id"]=> int(26) ["name"]=> string(10) "Porche 911" ["slug"]=> string(10) "porche-911" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(26) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(0) ["filter"]=> string(3) "raw" } } array(3) { [0]=> object(WP_Term)#7503 (10) { ["term_id"]=> int(25) ["name"]=> string(6) "Jaguar" ["slug"]=> string(6) "jaguar" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(25) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(0) ["filter"]=> string(3) "raw" } [1]=> object(WP_Term)#7490 (10) { ["term_id"]=> int(24) ["name"]=> string(13) "Mercedes K100" ["slug"]=> string(13) "mercedes-k100" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(24) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(0) ["filter"]=> string(3) "raw" } [2]=> object(WP_Term)#7489 (10) { ["term_id"]=> int(26) ["name"]=> string(10) "Porche 911" ["slug"]=> string(10) "porche-911" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(26) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(0) ["filter"]=> string(3) "raw" } }
So the name of my taxonomy field is called 'make' and for test purposes I just want to display all the posts that have a Taxonomy of 'Jaguar'
Please advise.
