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.

1 Answer 1

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 ) );
1
  • That put me in the right track, thanks. Just had to change 'cat_sd' => 12 to 'cat_sd' => 'slug_of_this_cat'
    – fana
    Commented Oct 5, 2010 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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