Created
August 24, 2015 13:05
-
-
Save mikejolley/e2e85f8883776211681c to your computer and use it in GitHub Desktop.
Replacement for https://github.com/woothemes/woocommerce/blob/master/templates/single-product/product-attributes.php#L52-L65 to show archive links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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