Title: wp_query for brands
Last modified: November 27, 2017

---

# wp_query for brands

 *  Resolved [matstillo](https://wordpress.org/support/users/matstillo/)
 * (@matstillo)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/wp_query-for-brands/)
 * Hi there, I could do with just outputting the brands in a way where I have more
   control over the loop other than those offered by the shortcodes. I think that
   the Brands are set up as a taxonomy, but I’d be really gratefull if someone could
   offer some help on how to display the brands via wp_query: the required arguments,
   then also the methods for outputting things like the title & image within that
   loop. At some point I also need to be able to only output Brands where an image
   has been added, as otherwise this breaks the layout on the site. The client will
   add the brands, than I need to play catch up & add the logo afterwards!
 * Many thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [titodevera](https://wordpress.org/support/users/titodevera/)
 * (@titodevera)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/wp_query-for-brands/#post-9726030)
 * Hi matstillo.
 * Brands are terms of the `pwb-brand` taxonomy, so you need to use `get_terms` 
   instead of `WP_Query`.
 *     ```
       $brands = get_terms( 'pwb-brand', array( 'hide_empty' => false) );
   
       foreach( $brands as $brand ) {
         $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
         $logo	= wp_get_attachment_image_src( $attachment_id, 'full' );
   
         echo 'Brand ID: '   . $brand->term_id . '<br>';
         echo 'Brand name: ' . $brand->name . '<br>';
         echo 'Brand logo: ' . $logo[0] . '<br>';
       }
       ```
   
 * And this for retrieving the brands of each product inside a custom WP_Query:
 *     ```
       $the_query = new WP_Query( array( 'post_type' => 'product', 'posts_per_page' => -1 ) );
       if ( $the_query->have_posts() ) {
         while ( $the_query->have_posts() ) {
           $the_query->the_post();
   
           $brands = wp_get_object_terms( get_the_ID(), 'pwb-brand' );
           var_dump( $brands );
   
         }
         wp_reset_postdata();
       }
       ```
   
 *  Thread Starter [matstillo](https://wordpress.org/support/users/matstillo/)
 * (@matstillo)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/wp_query-for-brands/#post-9728571)
 * Hi there,
 * That’s great stuff, nice support, thanks very much. That looks like that will
   do everything I need. Just on a slighty different note: I’m going to be using
   this so I can work with a modified setup of Slick Slider. In the meantime, I’m
   just using the carousel shortcode, but can’t get that to randomise the brands
   in the carousel:
 * [pwb-carousel items=”16″ items_to_show=”8″ items_to_scroll=”1″ image_size=”square_small”
   autoplay=”true” arrows=”false” order_by=”rand”]
 * It’s still just outputting them in alphabetical order. It looks like the ‘rand’
   option is set up in the plugin code, can you see why that might not be working?‘
   square_small’ is just a custom image size I have set up, which is working fine.
 * Many thanks again!
 * Mat
 *  Plugin Contributor [titodevera](https://wordpress.org/support/users/titodevera/)
 * (@titodevera)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/wp_query-for-brands/#post-9729802)
 * Hi matstillo.
 * The “Order by” option is not implemented for PWB carousels.
    I will consider 
   include it for future releases.
 * Here is more info about available shortcodes:
    [How can i use the available shortcodes without Visual Composer?](https://github.com/titodevera/perfect-woocommerce-brands/wiki/How-can-i-use-the-available-shortcodes-without-Visual-Composer%3F)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wp_query for brands’ is closed to new replies.

 * ![](https://ps.w.org/perfect-woocommerce-brands/assets/icon-256x256.jpg?rev=2912506)
 * [Perfect Brands for WooCommerce](https://wordpress.org/plugins/perfect-woocommerce-brands/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/perfect-woocommerce-brands/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/perfect-woocommerce-brands/)
 * [Active Topics](https://wordpress.org/support/plugin/perfect-woocommerce-brands/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/perfect-woocommerce-brands/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/perfect-woocommerce-brands/reviews/)

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 3 replies
 * 2 participants
 * Last reply from: [titodevera](https://wordpress.org/support/users/titodevera/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/wp_query-for-brands/#post-9729802)
 * Status: resolved