Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
So Yoast SEO has an issue where you can't define a global default twitter card image.
So I'm looking to both set a default twitter card image but allow for the override on the specific pages to actually work.
I'm currently using:
$default_opengraph = 'https://website.com/image.png';
function default_opengraph() {
global $default_opengraph; return $default_opengraph;
}
add_filter('wpseo_twitter_image','default_opengraph');
Which allows me to globally set the default twitter card image, but the problem with this is:
- It prevents page specific overrides from working (Yoast SEO Customs / Featured Image)
- It needs to be manually defined.
Anyone able to help find a fix for this, it's something YoastSEO itself should have in the plugin and they have loads of requests on WordPress forums, github as well as on their site asking for this and they've been asking for several years but they still haven't added it...
Hopefully someone can help with this as it's largely applicable and useful for many many users.
Thanks