Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Created September 20, 2022 18:44
Show Gist options
  • Save jrick1229/7cc2123e728647d50711062a66bb5b27 to your computer and use it in GitHub Desktop.
Save jrick1229/7cc2123e728647d50711062a66bb5b27 to your computer and use it in GitHub Desktop.
[WooCommerce Brands]: Add brand name to single product page
<?php
/*
* Increase `1` on line 7 to move position of brand name
*/
add_action( 'woocommerce_single_product_summary', 'wc_brands_add_brand_name', 1 );
function wc_brands_add_brand_name() {
global $product;
$brands = implode(', ', wp_get_post_terms($product->get_id(), 'product_brand', ['fields' => 'names']));
echo "<p>Brand: " . $brands . "</p>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment