Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created August 24, 2015 13:05
Show Gist options
  • Save mikejolley/e2e85f8883776211681c to your computer and use it in GitHub Desktop.
Save mikejolley/e2e85f8883776211681c to your computer and use it in GitHub Desktop.
<?php
if ( $attribute['is_taxonomy'] ) {
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'ids' ) );
$links = array();
foreach ( $values as $value ) {
$term = get_term_by( 'id', $value, $attribute['name'] );
$links[] = '<a href="' . esc_url( get_term_link( $term->slug, $attribute['name'] ) ) . '">' . esc_html( $term->name ) . '</a>';
}
echo apply_filters( 'woocommerce_attribute', wpautop( implode( ', ', $links ) ), $attribute, $values );
} else {
// Convert pipes to commas and display values
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment