Hello,
Thank you for contacting Rank Math today.
The schema will pick the featured images by default but you can use the following code in your functions.php file to assign a custom image to the schema:
/**
* Filter to modify Software Application schema
*
* @param array $entity Snippet Data
* @return array
*/
add_filter( 'rank_math/snippet/rich_snippet_software_entity', function( $entity ) {
global $post;
if($post->ID =='123'){ //target certain post id
$entity['image']['url'] = 'https://domain.com/image.jpg';
return $entity;
}
return $entity;
});
You can use the class name “rank-math-review-data” to create some custom CSS to style the shortcode output data.
Looking forward to helping you. Thank you.
Hi Michael,
Thanks for the sharing the code. I’m guessing I would need to specify this for all posts on my site where i want to use another image?
If yes, can you send me a revised quote for 3 posts? I want to make sure, future edits are covered.
At this point i have less than 15 posts with reviews attached to them and i want to remove the extra review plugin from my site to cater to those 15…
Also, please share the name for ‘Product’ schema type. I may have to use those in a couple of instances.
Thanks again. Youre a life saver…
Hello,
Thank you for contacting Rank Math today.
Here is a revised version for 3 posts:
/**
* Filter to modify Software Application schema
*
* @param array $entity Snippet Data
* @return array
*/
add_filter( 'rank_math/snippet/rich_snippet_software_entity', function( $entity ) {
global $post;
if($post->ID =='123'){ //target certain post id
$entity['image']['url'] = 'https://domain.com/image.jpg';
return $entity;
}elseif($post->ID =='234'){ //target certain post id
$entity['image']['url'] = 'https://domain.com/image2.jpg';
return $entity;
}elseif($post->ID =='456'){ //target certain post id
$entity['image']['url'] = 'https://domain.com/image.jpg';
return $entity;
}else($post->ID =='789'){ //target certain post id
$entity['image']['url'] = 'https://domain.com/image.jpg';
return $entity;
}
return $entity;
});
The last request is not very clear, would you like to modify the image for the product schema as well?
Looking forward to helping you. Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.