WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i hope you are well today,

My question is just breif i am trying to query from a custom post type by a certain taxonomy only;

to keep it streamline lets use the below as an example;

Custom Post Type: 'Products';

Taxonomy: 'Categories';

Categories within 'Categories';

(1) Category 1 (2) Category 2 (3) Category 3

So i would like query posts from the Custom Post Type 'Products' and within 'Category 1'

How would this be done ?

Here is my code for what querying the custom post type and attempting to query the taxonomy category.

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $post_per_page = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    'post_type' => 'products',
    'taxonomy' => 'category-1',
    'paged' => $paged,
    'posts_per_page' => $post_per_page,
    'order' => 'ASC',
    $temp = $wp_query;  // assign orginal query to temp variable for later use
    $wp_query = null;
    $wp_query = new WP_Query($args);
    if( have_posts() ) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
share|improve this question
up vote 6 down vote accepted

There are 3 ways of doing that:


'category_name' => 'category-1'



'taxonomy' => 'category',
'term' => 'category-1',



'tax_query' => array(
  array( 'taxonomy' => 'category', 'terms' => array( 'category-1' ) )

More info: http://codex.wordpress.org/Function_Reference/WP_Query

share|improve this answer
thanks man your a star ! <3 – Xavier Apr 1 '11 at 11:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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