Site logo

Archived topic

inserted pa_attribute after woo product title, how to assign a class for styling

2 replies · Started by Stacie Kliber on January 15, 2019

Viewing posts 1–3 of 3

Hi all at GP, I've inserted a Woo attribute to display after the product title using the action below - but now I can't figure out how to assign a class to the attribute. Can it be done inside the snippet below? p.s. I know just enough to be dangerous, but I find answers to many of my questions here (so thank you!).

/*add location after project title*/
add_action('woocommerce_shop_loop_item_title', 'wh_insertAfterShopProductTitle', 15);

function wh_insertAfterShopProductTitle() {
global $product;

$location = $product->get_attribute('pa_location');
if (empty($location))
return;
echo __($location, 'woocommerce');
}

Any helpful info or resource would be much appreciated. :)

Thanks

GP Premium 1.7.5

Here's what I did:

/*add location after project title*/
add_action('woocommerce_shop_loop_item_title', 'wh_insertAfterShopProductTitle', 15);

function wh_insertAfterShopProductTitle() {
global $product; $location = '<h6>' . $product->get_attribute('pa_location') . '</h6>';
if (empty($location)) return;
echo __($location, 'woocommerce');
}

Glad you figured out :)

This archived topic is closed to new replies.