Skip to content

Instantly share code, notes, and snippets.

@bigdawggi
Created January 3, 2013 15:46
Show Gist options
  • Save bigdawggi/4444407 to your computer and use it in GitHub Desktop.
Save bigdawggi/4444407 to your computer and use it in GitHub Desktop.
Super-simple fall-back open graph image for your WordPress blog. I didn't want/need a whole plugin for this, just wanted a simple og:image fall-back for my site.
<?php
// Add this to your functions.php file
function mgr_og_image_fallback() {
if (!has_post_thumbnail()) {
// Replace the image URL unless you want my mug as your image for Open Graph Image ;)
?>
<meta property="og:image" content="http://i1.wp.com/matthewgrichmond.com/files/2012/03/matt.jpg?resize=310%2C180" />
<?php
}
}
add_action('wp_head', 'mgr_og_image_fallback');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment