I'm currently building a theme using Understrap. I want to add images to attributes. Right now, i'm using the following plugin : Advanced Category and Custom Taxonomy Image but i can't figure out how to display my images along with their text in my single-product page.
Right now, i've done the following :
/**
* Add a custom product data tab
*/
add_filter('woocommerce_product_tabs', 'woo_new_product_tab');
function woo_new_product_tab($tabs)
{
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __('Ingredients', 'woocommerce'),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
/**
* Remove product data tabs
*/
add_filter('woocommerce_product_tabs', 'woo_remove_product_tabs', 98);
function woo_remove_product_tabs($tabs)
{
unset($tabs['additional_information']); // Remove the additional information tab
return $tabs;
}
function woo_new_product_tab_content()
{
echo '<h2>Ingredients</h2>';
// echo '<p>Here\'s your new product tab.</p>';
global $product;
$attributes = $product->get_attribute('ingredients');
foreach ($attributes as $attribute) {
$terms = wp_get_post_terms($product->get_id(), $attribute['name']);
foreach ($terms as $term) {
$taxonomy_img = get_taxonomy_image($term->term_id);
}
}
print $attributes;
}
But it only displays the text and not the images. What am i missing ?