Hello again,
I wanted to elaborate a bit more on this one, since I realized what’s wrong.
My posts do not have a featured image set, nor the content itself has any photo content, so by reading the docs more carefully, it correctly show the default local seo image.
However, each of my posts might have several attachments bound to the post – so what I am trying to do is to replace the default og:image on demand only when a post has attachments on it. Reading your docs, I would expect the following filter to work, but it doesn’t. Is there any other option I am missing?
add_filter( "rank_math/opengraph/{$network}/image", function( $attachment_url ) {
return $attachment_url;
});
I tried both facebook and twitter without luck. Any help?
Hello @scooterlord,
Thank you for contacting the support and sorry for not following up quickly and any inconvenience that might have been caused due to that.
By default we use the image from Titles & Meta >> Global Meta.
Please check this screencast:
https://i.rankmath.com/SEJgQx
The opengraph/$network/image
filter is working fine. You will have to change the $network
variable to facebook
or twitter
:
add_filter( "rank_math/opengraph/facebook/image", function( $attachment_url ) {
return 'https://google.com/image.png';
});
Hope that helps.
Thank you for your reply. Actually it was a caching issue, worked my way through it! Thanks a million!
Hello @scooterlord
Glad that’s sorted.
If it isn’t too much to ask for – would you mind leaving us a review here?
https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post
It only takes a couple of minutes but helps us tremendously.
It would mean so much to us and would go a really long way.
Thank you.