This snippet will pull the cover field on your single post and will use that as the OG:IMAGE when sharing the link.
THIS CODE ONLY WORKS WITH SEOPRESS PLUGIN
SEOPRESS PLUGIN ONLY
function sp_social_og_thumb_dynamic_multiple_ids($html) {
if (is_single()) {
global $post;
$image_id = get_post_meta($post->ID, 'cover', true); // Retrieve the 'cover' field, assuming it returns a single image IDif (!empty($image_id)) {
$first_image_url = wp_get_attachment_url($image_id); // Get the full URL of the imageif ($first_image_url) {
$html = '<meta property="og:image" content="' . esc_url($first_image_url) . '" />';
}
}
}
return $html;
}
add_filter('seopress_social_og_thumb', 'sp_social_og_thumb_dynamic_multiple_ids');