I have a custom post type 'products' and custom taxonomy of 'maker' that i have connected to that cpt 'products'. I have written this code :

  <?php $myproducts = new WP_Query(array('post_type' => 'products', 'maker'=>'samsung')); ?>
  <?php while($myproducts->have_posts()) : $myproducts->the_post(); ?>

  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

  <?php endwhile; ?>
  <?php wp_reset_postdata(); ?>

and this allows me to loop products from one of added makers (in this case samsung). What I am actually trying to do is to create a page that will loop through all of items from 'maker' taxonomy that a client might add to it. It would be great if I could use these elements of the 'maker' taxonomy to show lists of all 'products' that belong to those makers. Basically loop the taxonomy elements and use those results to loop all products that belong to those makers. Sorry if i'm being redundant, I'm just trying to be as specific as a beginner might be. Thank you all.

2 Answers 2


You can simply use a tax query to get all posts attached to any product_cat term:

$args = array(
    'post_type' => 'product',
    'tax_query' => array(
            'taxonomy' => 'product_cat',
            'terms' => get_terms( 'product_cat', 'fields=ids' ),
    'orderby' => 'menu-order',

Use this code to get product by category.

<?php $args = array( 'post_type' => 'product','product_cat' =>'sumsung', 'orderby' => 'menu-order' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<?php the_post_thumbnail(); ?>
<?php the_title();?>           
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>"></a>  
<?php endwhile;?>
  • thanks for trying Shafi, I tried your approach, but im getting an error, it seems its from the key-value pair that you have 3 items in there product_cat => maker => samsung.. Jan 16, 2014 at 11:55
  • @user44772 I remove 'maker' on above code. check it again. Jan 16, 2014 at 12:00
  • ..tried it again, I get a list of all products from my product custom post type. But that was not my problem, i wanted to print a list of all makers with all products that go along with those maker taxonomies. I appreciate the effort Jan 16, 2014 at 12:11

Your Answer

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

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