Hello,
Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.
You can implement this with our plugin with the help of the following filter: https://rankmath.com/kb/filters-hooks-api-developer/#change-opengraph-image
For example, let’s say you have a field called og-image in ACF and you want to set that as the OpenGraph image, the following code should achieve that:
add_filter( "rank_math/opengraph/facebook/image", function( $attachment_url ) {
$new_image_url = get_field('og-image');
if($new_image_url){
$attachment_url = $new_image_url;
}
return $attachment_url;
});
add_filter( "rank_math/opengraph/twitter/image", function( $attachment_url ) {
$new_image_url = get_field('og-image');
if($new_image_url){
$attachment_url = $new_image_url;
}
return $attachment_url;
});
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how it goes. 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.