Hello,
I apologize for the issue you are facing. Currently, Rank Math does not support dynamically changing the social card image or title based on the latest featured image or post title from the homepage. The social card image and title need to be set manually for each post or page.
However, you can set a default Open Graph Thumbnail for all pages on your website, and if your homepage is set to display your latest posts, you can change the homepage Open Graph thumbnail under Rank Math SEO → Titles & Meta → Homepage → Homepage Thumbnail for Facebook. This will allow you to set a specific image for the homepage that will be used when shared on social media.
If you would like to have different images or titles for individual posts, you will need to configure them in the Rank Math Metabox for each post.
For more detailed guidance, you can refer to the following resources:
If you have any further questions or if this does not address your needs, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.
Sources:
Open Graph/Social Preview Image Is Not Displayed » Rank Math
Open Graph/Social Preview Image Is Not Displayed » Rank Math
Open Graph Meta Tags » Rank Math
Would be a great feature to add! Or maybe dynamically through elementor?
Hello,
Thank you for your patience.
You can use this filter to dynamically use the featured image set on your homepage as the og:image tag every time it changes on your site:
add_filter( "rank_math/opengraph/facebook/image", function( $attachment_url ) {
if ( is_front_page() && has_post_thumbnail() ) {
// Get the featured image URL
$attachment_url = get_the_post_thumbnail_url(get_option('page_on_front'), 'full');
}
return $attachment_url;
});
Here’s a guide to adding the code to the website:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Looking forward to helping 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.