I have a custom post type (portfolio-type) with a custom hierarchical taxonomy (portfolio-category)
Now I would like to query only posts from potrfolio-type, so i do:
$paged = 1;
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');
query_posts( '&post_type=portfolio-type&paged=' . $paged );
And till here, everything works great. Now, I would like to query only posts, that are in any, of children custom taxonomy "categories" of a custom taxonomy category with given ID.
So I tried:
$paged = 1;
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');
$query_args = array(
'post_type' => 'portfolio-type',
'cat' => $CAT_ID,
'paged' => $paged,
);
query_posts( $query_args );
Failed (no results), but I understand Why. those posts are not in standard category, but in custom taxonomy's category, so looking at wp Codex, this is what I came with:
$query_args = array(
'post_type' => 'portfolio-type',
'paged' => $paged,
'tax_query' => array(
'taxonomy' => 'portfolio-category',
'field' => 'id',
'terms' => $CAT_ID
)
);
Failed again, but this time all custom posts from portfolio-type post_type displays (tax_query doesnt work, whatever ID i put there result is all the same)
What am I missing?
array(...)
, compare with the example there. - If something does not work as thought, check with the docs first, double-check if everything has been written properly.