woocommerce function: add product title and brand to image alt tag in archive page

Concluído Postado há 4 anos Pago na entrega
Concluído Pago na entrega

i’d like to use this code to add automatically product name and product brand to the alt text of images. `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;

}`

this code add product title; how to add the brand with it separated with space

PHP WordPress WooCommerce Arquitetura de software JavaScript

ID do Projeto: #22583979

Sobre o projeto

1 proposta Projeto remoto Ativo em há 4 anos

Concedido a:

moxdesigns

Good day, I bid on your project as I feel confident I can complete this task. I have advanced English Skills and I can start working right away. My Skills are exactly what you are looking for. Send me a message so we c Mais

$25 USD em 1 dia
(230 Comentários)
6.9