Attribute link removed product and image link
-
Hi, I have a custom attribute named ‘ State’ that is being called by the code below from your webpage.
I have two issues:
1. The product image and product title links have been removed and now linked to ‘State’ which is confusing for customers. Is there a way to move the link back to the product title /product image?2. The result from the input of the state (e.g California) is linked which is a great way to filter but the term itself ‘State’ appears.
For example, it shows State: California, I would like it to just show California while hiding State and keeping the link on California for filtering purposes.
Thanks for your time.
/**
* Display product attribute archive links
*/
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘wc_show_attribute_links’,5);// if you’d like to show it on archive page, replace “woocommerce_product_meta_end” with “woocommerce_shop_loop_item_title”
function wc_show_attribute_links() {
global $post;
$attribute_names = array( ‘pa_state’ ); // Add attribute names here and remember to add the pa_ prefix to the attribute nameforeach ( $attribute_names as $attribute_name ) {
$taxonomy = get_taxonomy( $attribute_name );if ( $taxonomy && ! is_wp_error( $taxonomy ) ) {
$terms = wp_get_post_terms( $post->ID, $attribute_name );
$terms_array = array();if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$archive_link = get_term_link( $term->slug, $attribute_name );
$full_line = ‘‘. $term->name . ‘‘;
array_push( $terms_array, $full_line );
}
echo $taxonomy->labels->name . ‘ ‘ . implode( $terms_array, ‘, ‘ );
}
}
}
}The page I need help with: [log in to see the link]
- The topic ‘Attribute link removed product and image link’ is closed to new replies.