I am trying to add open graph meta data for og:image via custom field on Wordpress reference to this link but it does not work for me. Is this function correct? I am following all steps same.
PS: I dont use plugin for SEO
thanks
function insert_og_image() {
if(get_post_meta(get_the_ID(), 'og_image', true) && is_single()) {
$output = '<meta property="og:image" content="'. get_post_meta(get_the_ID(), 'og_image', true) .'" />';
}
echo $output;
}
add_action('wp_head','insert_og_image');