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]
- How to change product title color in shop page if product has specific product tag (Woocommerce)?
- 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
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Add custom field to attachments in a specific category
- WooCommerce – Customer Order History Pagination
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- 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 – Display variation custom field value [closed]
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products [closed]
- Woocommerce HTML email option unavailable
- How to add SVG icon above product tab title
- WooCommerce: update custom fields after checkout validation failure
- Use is_product_category() properly
- Highlight Current Tag in wp_tag_cloud
- My Own layout in WooCommerce pages [closed]
- Woocommerce – remove product from category
- 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?
- WooCommerce – Reset quantity input field when variation changes
- get current product name in functions.php
- tracking number field in Woocommerce order [closed]
- Way to querry data (tags) from a wordpress database?
- Image as Sales Badge
- Automatically remove a canceled order in Woocommerce
- Passing the custom field values in the wp_get_current_user array function
- Two Different Links for Same Product – WooCommerce [closed]
- How can I apply_filters from inside a function?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- 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?
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- 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
- Trouble checking if custom woocommerce checkout field is empty or not
- 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]
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Which PHP page is the Default Posts Page
- Edit the_category (); for a hierarchical display
- Need to put a script above tag in header.php – WP 5.7.1
- How to check if a PHP string is different than meta field?
- Can’t save php string to a custom field
- Filtering a function’ output for a new continued function
- Why does this update_post_meta function not delete the custom field itself?
- How to show/hide php table rows based on the content of custom fields
- Discount in the specific product title using keyword ( Woocoommerce )
- Including user data in “new user notification email”
- 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
- How to auto-generate random numbers in username?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- WP_Query To Display Product Of Brand On Taxonomy Page
- Woocommerce Add custom “Add to cart button” in single page with tags
- Exclude specific product tags from related products in WooCommerce 3+ [closed]
- 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
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- The search doesn’t work properly
- 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]
- Change WooCommerce Order status from frontend form submitted data
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- Add text below WooCommerce short description if metabox value is true
- ACF number less than comparison not working
- Woocomerce custom add to cart button edit functionality [closed]
- How to capture number input from wordpress form into acf field in woocommerce
- How to get default variation ID (woocommerce)
- Exclude function for custom pages, exclude custom ACF fields
- Assign a value (got from an xml file) to an attribute of Woocommerce products