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?