Yoast change their way to change og:image and remove wpseo_opengraph
functions and replaced it with
wpseo_frontend_presenters
, Now I want to change the value of og:image, the thing I don't get it is how to replace the value of og:image instead of adding a second og:image, the code below only adds new og:image at the bottom instead of replacing the value of the original og:image (see screenshot and code)
screenshot: https://prnt.sc/uugb0p
use Yoast\WP\SEO\Presenters\Abstract_Indexable_Presenter;
class My_Presenter extends Abstract_Indexable_Presenter {
public function present() {
return '<meta property="og:image" content="//d1id9ov24n1lx4.cloudfront.net/wp-content/uploads/2019/05/21155632/eview_home_hero.jpg" />';
}
public function get() {
// return $this->presentation->open_graph_image === 'nl_NL' ) ? 'Dutch' : 'Not dutch';
}
}
function add_my_presenter( $presenters ) {
$presenters[] = new My_Presenter();
return $presenters;
}
add_filter( 'wpseo_frontend_presenters', 'add_my_presenter' );
I saw this GitHub link and read it: https://github.com/Yoast/wordpress-seo/issues/14698 But I don't get how to use replace_vars, I'm not even sure if that's the correct way to change og: image value