Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // make attributes into links
- // code goes in functions.php for your child theme
- add_filter ('woocommerce_attribute', 'link_attributes', 10, 3);
- function link_attributes($attributes_string, $attribute, $terms) {
- global $post;
- $taxonomy = get_taxonomy( $attribute['name'] );
- if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
- $attribute_string = '';
- $terms = wp_get_post_terms( $post->ID, $taxonomy->name );
- if ( !empty( $terms ) ) {
- foreach ( $terms as $term ) {
- if (strlen($attribute_string) > 0) {
- $attribute_string .= ', ';
- }
- $archive_link = get_term_link( $term->slug, $attribute['name'] );
- $attribute_string .= '<a href="' . $archive_link . '">'. $term->name . '</a>';
- }
- }
- }
- return '<p>'.$attribute_string.'</p>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement