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') ?>" />


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.

1 Answer 1



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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.