SHARE
TWEET

Untitled

a guest Jun 18th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Change alt & title attributes of main product image to product name.
  2. add_filter('wp_get_attachment_image_attributes', 'taisho_change_image_attributes', 20, 2);
  3. function taisho_change_image_attributes($attr, $attachment) {
  4.     global $post;  
  5.     if ($post->post_type == 'product') {
  6.         $product = wc_get_product( $post->ID );
  7.         $authortags = strip_tags ($product->get_tags());
  8.         $title = $post->post_title;
  9.         $attr['alt'] = $title .' '. $authortags;
  10.         $attr['title'] = $title .' '. $authortags;
  11.     }  
  12.     return $attr;  
  13. }
  14.      
  15. apply_filters( 'woocommerce_single_product_image_thumbnail_html', wc_get_gallery_image_html( $attachment_id ), $attachment_id );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top