WordPress
Get started with integrating Mosaic into your WordPress project.
Step 1
Open your WordPress theme’s functions.php file (Appearance > Theme Editor > Theme Functions – functions.php).
function add_dynamic_og_image() {
// Get the current post slug
global $post;
$current_slug = $post->post_name;
// Construct the dynamic OG image URL
$og_image_url = 'https://mosaicimg.com/use?url=yourwebsite.com/' . $current_slug;
// Output the OG image meta tag
echo '<meta property="og:image" content="' . esc_url($og_image_url) . '" />';
}
add_action('wp_head', 'add_dynamic_og_image');
Step 2
Remember to replace the placeholder value (like 'yourwebsite.com') with your actual website URL.