Preview:
// Update the custom field with the dynamic OG image URL
// function update_og_image_field($post_id) {
// if (has_post_thumbnail($post_id)) {
// $image_url = generate_dynamic_og_image($post_id); // Generate the dynamic OG image URL
// update_post_meta($post_id, 'og_image', $image_url);
// }
// }
// add_action('save_post', 'update_og_image_field');

// // Retrieve the OG image URL and include it in the <meta> tags
// function display_og_image() {
// if (is_singular()) {
// $post_id = get_queried_object_id();
// $og_image = get_post_meta($post_id, 'og_image', true);
// if (!empty($og_image)) {
// echo '<meta property="og:image" content="' . esc_url($og_image) . '">';
// }
// }
// }
// add_action('wp_head', 'display_og_image');
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter