Preciso consultar todas as postagens que pertencem a uma determinada categoria (padrão, não personalizada) e um tipo de postagem personalizado. Tão simples como isso. O fato de não funcionar, para mim, é ridículo. A menos que eu esteja perdendo alguma coisa?
Aqui está o que eu tentei:
$args=array(
'posts_per_page' => 50,
//'taxonomy' => 'category',
'post_type' => 'my_custom_type'
'category__in' => array($cat_id),
);
$wp_query = new WP_Query( $args );
então
$args=array(
'posts_per_page' => 50,
'post_type' => 'my_custom_type'
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $cat_id,
),
),
);
$wp_query = new WP_Query( $args );
e claro
$args=array(
'posts_per_page' => 50,
'post_type' => 'my_custom_type'
'category' => $cat_id,
);
$wp_query = new WP_Query( $args );
também, algumas combinações de adicionar/renomear/remover as chaves $args
.
Conseguir todos os posts por um tipo de post e, em seguida, fazer um loop através deles e filtrar por uma categoria não é uma opção eficaz, acredito.
Por favor ajude.
tente isso, é trabalho para mim.
$args=array(
'posts_per_page' => 50,
'post_type' => 'my_custom_type'
'cat' => $cat_id,
);
$wp_query = new WP_Query( $args );
Categoria Parâmetros
cat (int): use category id.
category_name (string): use category slug (NOT name).
category__and (array): use category id.
category__in (array): use category id.
category__not_in (array): use category id.