Getting the Product Attribute Term Permalink in WordPress / WooCommerce -
i'm using woocommerce wordpress build store of antique photos.
i'm using woocommerce product attributes feature store information item photographer.
see here example, photographer attribute pulled out in box on left http://bit.ly/1dp999o
the code pulls out attribute looks this:
if($attribute['is_taxonomy']) { $values=wc_get_product_terms($product->id, $attribute['name'], array('fields' => 'names')); echo apply_filters('woocommerce_attribute', wpautop(wptexturize(implode(', ', $values))), $attribute, $values); }
$values looks this:
array ( [0] => photographer 1 )
the problem is, how permalink photographer automatically generated wordpress , woocommerce: http://bit.ly/1jtwbna
i can't find documentation within woocommerce, , seems taxonomy within taxonomy goes bit further stabdard wordpress, i'm assuming standard requirement. pointers appreciated.
once have attribute term (in case photographer's name) can use get_term_link()
url. because $product
id isn't passed woocommerce_attribute
folder, couldn't filter that, instead create override of product-attributes.php
template. , modified relevant section following:
if ( $attribute['is_taxonomy'] ) { $terms = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'all' ) ); $html = ''; $counter = 1; $total = count( $terms ); foreach( $terms $term ){ $html .= sprintf( '<a href="%s" title="permalink %s">%s</a>', esc_url( get_term_link( $term ) ), esc_attr( $term->name ), wptexturize( $term->name ) ); if( $counter < $total ){ $html .= ', '; } $counter++; } echo wpautop( $html ); }
for reason, url isn't pretty permalink. it's late , can't tell if has configuration or exactly, start.