I’ve created a custom post type and custom taxonomy. I can now create a new post and associate it with a custom category.
The problem is listing these news post types.
This:
$loop = new WP_Query( array( 'post_type' => 'sobeedesce' ) );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo "<br />";
endwhile;`
lists all custom posts ok. But I want to list them by category, so adding 'cat' => 12
returns nothing.
I know my custom category id is 12
and I can confirm that by doing
$custom_terms = get_the_terms(0, 'cat_sd');
print_r($loop);`
inside the loop.
I’m missing something here. Can someone help me?
Thanks.
I suppose your custom taxonomy slug is ‘cat_sd’, right?
If so, the right query would be: