Home › Forums › WoodMart support forum › Link Failure – Forwarding – Productpage – Brands Image Icon › Reply To: Link Failure – Forwarding – Productpage – Brands Image Icon
September 30, 2018 at 12:02 pm
#79919
Artem Temos
Keymaster
Try to add the following PHP code snippet to the child theme functions.php file
function woodmart_product_brands_links() {
global $product;
$brand_option = woodmart_get_opt( 'brands_attribute' );
$brands = wc_get_product_terms( $product->get_id(), $brand_option, array( 'fields' => 'all' ) );
if( !woodmart_get_opt( 'brands_under_title' ) || empty( $brands ) ) return;
$link = ( defined( 'SHOP_IS_ON_FRONT' ) ) ? home_url() : get_permalink( wc_get_page_id( 'shop' ) );
echo '<div class="woodmart-product-brands-links">';
foreach ( $brands as $brand ) {
$filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $brand_option ) );
$attr_link = apply_filters( 'woodmart_brands_link', add_query_arg( $filter_name, $brand->slug, $link ), $brand );
$sep = ', ';
if ( end( $brands ) == $brand ) $sep = '';
echo '<a href="' . esc_url( $attr_link ) . '">' . $brand->name . '</a>' . $sep;
}
echo '</div>';
}