Replace Yoast og:image in single custom post type
I'm trying to replace the custom yoast og:image in a specific post type to use a custom meta field instead of the featured image. What I got so far is:
function my_wpseo_opengraph()
{
global $post;
if (is_singular('job_listing')) {
$og_image = get_post_meta($post-ID, 'pp_job_header_bg', TRUE);
if (!empty ($og_image)) {
$GLOBALS['wpseo_og']-image($og_image);
}
}
}
add_action('wpseo_opengraph', 'my_wpseo_opengraph', 29);
However, while viewing the source code, it seems that the code won't replace the default og:image, it adds a second og:image.
How do I replace it?
Topic plugin-wp-seo-yoast plugins Wordpress
Category Web