Change meta tags programatically
Is there a way to change the meta tags not in the head but in a template file through code?
I would like to change the meta tags
meta property="og:title" content="title" /
meta property="og:description" content="description" /
meta property="og:image" content="thumbnail_image" /
They are automatically set when calling the facebook SDK. Is there a way to change these tags in my code (not in header.php)?
I've tried to do this in my child template (content-share.php):
?php
add_action( 'wp_head', 'add_meta_tags' , 10 );
?
And then in functions.php of my theme I have:
function add_meta_tags() {
echo 'meta property="og:title" content="Test"' . "\n";
}
But that doesn't do anything. Also when I add a die;
in the function nothing changes. It's like my function isn't called.
How can I solve this?