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();
}
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
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?