2

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.

2

I suppose your custom taxonomy slug is 'cat_sd', right?

If so, the right query would be:

$loop = new WP_Query( array( 'post_type' => 'sobeedesce', 'cat_sd' => 12 ) );
  • That put me in the right track, thanks. Just had to change 'cat_sd' => 12 to 'cat_sd' => 'slug_of_this_cat' – fana Oct 5 '10 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.