How to replace the existing metatag using the backend to insure a thumbnail image gets fetched when we share on social media?

How to replace the existing metatag using the backend to insure a thumbnail image gets fetched when we share on social media?

function theme_a_header_metadata() {

  global $post;

  $image = \wpplugin\blogwidget\getBlogImage($post);

?

  meta property=og:image content=?= getLocalImage($image, '1344x') ? /

?php

}
add_action( 'wp_head', 'theme_a_header_metadata' );

So I have this function, but the issue is that there's already a meta property with the property value of og:image, so how do I replace the meta tag? I need to use the backend, and I don't want to install any plugin.

Topic wp-head plugin-development Wordpress

Category Web


add_action

add_action currently supports 4 parameters: string $hook_name, callable $callback, int $priority = 10, int $accepted_args = 1

Try adjusting the 3rd parameter "priority" to add the action later than any existing actions (which may have been created by plugins or themes).

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.