The Perfect Brands for WooCommerce plugin allows users to display a list of all brands of products. However, there is no shortcode available to show this list. By adding a specific code to the functions.php file of the theme being used and inserting the shortcode [brand_list], users can now easily display the list of brands on their website. The code provided fetches the taxonomy of brands and displays them in alphabetical order. This solution helps users effectively showcase all brands associated with their products.
When using the "Perfect Brands for WooCommerce" plugin to manage your product brands, you might need to display a list of all those brands. However, the plugin doesn’t come with a shortcode to show that list.
Today, I’ll share the following code snippet that you can add to the functions.php file of your current theme. Then, simply insert the shortcode [brand_list] wherever you want the list to appear.
function brand_list() {
ob_start();
//code to retrieve taxonomy
$args_tax = array(
'taxonomy' => 'pwb-brand',
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC'
);
$cats = get_categories($args_tax);
if($cats) {
echo '</pre>';
}
$brand_list = ob_get_contents();
ob_end_clean();
wp_reset_postdata();
return $brand_list;
}
add_shortcode('brand_list','brand_list');
This code snippet will help you display the list of brands associated with the "Perfect Brands for WooCommerce" plugin on your website. Just follow the instructions above to implement it.