Skip to content

Instantly share code, notes, and snippets.

@digitalinkwell
Created March 26, 2016 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalinkwell/c767824d3ff5e7e40bd0 to your computer and use it in GitHub Desktop.
Save digitalinkwell/c767824d3ff5e7e40bd0 to your computer and use it in GitHub Desktop.
function fb_opengraph() {
global $post;
if(is_single()) {
if(has_post_thumbnail($post->ID)) {
$img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium');
} else {
$img_src = get_stylesheet_directory_uri() . 'url-to-your-image-here.jpg';
}
if($excerpt = $post->post_excerpt) {
$excerpt = strip_tags($post->post_excerpt);
$excerpt = str_replace("", "'", $excerpt);
} else {
$excerpt = get_bloginfo('description');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment