Display list of only specific tags on product
Good afternoon,
I know I'm doing this wrong, looked at all the other questions but can't get it figured out. I have a tag list with images assigned that are displayed in a separate area of my site. I don't want to display all the tags assigned to the product, only the specific tags; they are TAG1, TAG2, and TAG3. I attempted to put the below in to see if it would work but to no avail. My best guess is I need to create an array to put the tag names in and inject them into the loop a different way.
Thanks in advance
public function shortcode_custom_tags() {
if ( is_product() || is_shop() ) {
ob_start();
global $product;
//var_dump($product);
$product_tags = get_the_terms( $product-get_id(), 'product_tag' );
if ( ! is_array( $product_tags ) ) {
return $product_tags;
}
?
div class=img-listings
label style=font-weight: bold; font-size: 16px;Works with/label
ul
?php
foreach ( $product_tags as $product_tag ) {
if ( $product_tag-slug = [TAG1, TAG2, TAG3]) {
$img_url = get_option( 'z_taxonomy_image' . $product_tag-term_id );
$this-format_setting( $product_tag-name, $img_url, $product_tag-term_id );
}
}
?
/ul/div
?php
} else {
return;
}
return ob_get_clean();
}
Topic woocommerce-offtopic tags Wordpress
Category Web