tags:

views:

68

answers:

1

I am able to retrieve all the posts from a custom category with this call to WP_Query

$q = new WP_Query(array( 'taxonomy' => 'jh-portfolio-category',
                          'term' => 0, 'post_type' => 'jh-portfolio' ));

However, let say within the jh-portfolio-category taxonomy I have defined some sub-categories, how do I specify I wish to have posts from a specific sub-category? Changing the 'term' property to the term_id as presented in wp_term_taxonomy doesn't seem to work. All the posts within that taxonomy is still being listed.

A: 

I'm not sure if this is helpful to you. I had a similar problem where I was trying to get_posts that were of a custom post_type and taxonomy.

The name of your post_type is jh-portfolio. Your taxonomy is called jh-portfolio-category. You didnt specify the name of your term in your post, so lets call it foobar. Your get_posts or query_posts function would look like this:

  get_posts("post_type=jh-portfolio&jh-portfolio-category=foobar");
query_posts("post_type=jh-portfolio&jh-portfolio-category=foobar");

I'm not sure how this would translate to WP_Query, but if I had to guess, I would say:

$q = new WP_Query(array( 'jh-portfolio-category' => 'foobar',
                                     'post_type' => 'jh-portfolio' ));
Jazzerus