-
Hello,
I added this code in my functions.php to change the url of the product image in the Schema, but it doesn’t work.
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
if ( ! is_product() ) {
return $entity;
}$entity['image'][0]['url'] = 'NEW URL';
return $entity;
} );I also tried with
$image = [];
$image[] = [
'@type' => 'ImageObject',
'url' => 'NEW URL',
'height' => 614,
'width' => 1080,
];
$entity['image'] = $image;
but also no success. The returned array is always correct, but in the frontend it will always show the product image which is set in the WordPress backend.
Your example with changing the brand value works fine..
The ticket ‘Edit image value in Schema’ is closed to new replies.