This is what you need, taken from – https://stackoverflow.com/questions/27087772/how-can-i-change-meta-alt-and-title-in-catalog-thumbnail-product-thumbnail
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes( $attr, $attachment ){
// Get post parent
$parent = get_post_field( 'post_parent', $attachment);
// Get post type to check if it's product
$type = get_post_field( 'post_type', $parent);
if( $type != 'product' ){
return $attr;
}
/// Get title
$title = get_post_field( 'post_title', $parent);
$attr['alt'] = $title;
$attr['title'] = $title;
return $attr;
}
Related Posts:
- Edit tag cloud widget number
- WP All Import / Update stock quantity from multiple XML files
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to get the original price of the product in woocommerce?
- Woocommerce auto cancel On-Hold after X days
- Add custom field to attachments in a specific category
- WooCommerce – Customer Order History Pagination
- The values of custom fields are not available functions.php
- show limited tags in an article
- display most popular tags in two columns
- How can update custom meta for all posts
- Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products [closed]
- Use is_product_category() properly
- Highlight Current Tag in wp_tag_cloud
- Changing Woocommerce flat rate every nth number of items
- Limiting woocommerce line_total decimal length
- How do I display a user’s previous orders as a select box option on a product?
- How do you add customer capability after Woocommerce purchase?
- Way to querry data (tags) from a wordpress database?
- Passing the custom field values in the wp_get_current_user array function
- Two Different Links for Same Product – WooCommerce [closed]
- Auto-update products after they were published – Woocommerce
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Display a specific category of products in shop page and disable code for specific actions
- Woocommerce related product text
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Firing schema via code in functions.php doesn’t work
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How can I get the values of my WordPress $wpdb query in Jquery?
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Validation algorithm in checkout field
- My new button is in the wrong place
- Trying to retrieve post meta
- Redirect to another page using contact form 7? [closed]
- Edit the_category (); for a hierarchical display
- How to check if a PHP string is different than meta field?
- Filtering a function’ output for a new continued function
- Why does this update_post_meta function not delete the custom field itself?
- Custom meta box values are not getting saved for my custom post type
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- woocommerce specific quantities for product
- Personalize checkout text
- CSS change in woo commerce Place Order Text [closed]
- woocommerce related product title length
- How to add data to a custom field at the wp_users table?
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Custom Taxonomy Select Menu: Setting default option value?
- Hide a div when a custom field is empty
- Conditional On custom field plugin metabox
- Execute PHP code only with specific user role
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Modify WooCommerce used to get all orders in dashboard
- Output product category link from WP_Query
- Delete images from media library when user deletes an image from ACF Gallery
- Updating Metadata with Shortcode
- Woocommerce My acount page
- Woocommerce – Exclude variation attribute on specific variation
- Display custom field value in woocommerce variable product via jQurey
- Products listing check if meta checkbox is checked
- Is it possible to update the dataset using update_post_meta
- PHP function for horizontal Woocommerce thumbnails and badges
- Block error message in foreach loop when looping through ACF field
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Hide a div if the fiels is empty
- Hide payment method based on user role AND minimum cart value
- WooCommerce display price before add to cart [closed]
- Best way to use variables in multiple functions?
- Discount in the specific product title using keyword ( Woocoommerce )
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- Adding product permalink on admin order page throwing error
- How do I get the value of a current user’s custom field?
- Add Product Permalink in woocommerce admin order page
- How to override WooCommerce Order Item Meta with data from Cart?
- Woocommerce textarea format ignored
- WP_Query To Display Product Of Brand On Taxonomy Page
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WooCommerce multiple custom fields code
- Add missing alt tag to featured images for “storefront” theme
- Display text of price (minus 20%) on every product page in a sentence.
- Display product attributes for current product
- Use WP_Query Data In Cookie
- Insert wordpress tags below posts via functions.php
- How to get the rating value of each comment
- ACF Date fileds to Age Convert [closed]
- Setting WooCommerce currency programmatically
- Appending an ACF custom field to the page title
- how to loop through blog posts in php
- Warning: Attempt to read property “term_id” on int – Woocommerce
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- posts_clauses drop ACF get_field function
- Replace the image of a product with its video in the shop page
- Grabbing value of input field inside of array
- Automatically change insurance quantity based on cart total [closed]
- How call WordPress shortcode inside function file
- strict custom php script on specific product category [closed]
- How to pass value to add_filter wpcf7_form_tag from another function?