Created
April 26, 2012 14:30
-
-
Save madysondesigns/2499962 to your computer and use it in GitHub Desktop.
Opengraph thumbnails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In WP functions.php: | |
function get_post_id() { global $wp_query; $id = $wp_query->post->ID; return $id; } | |
function opengraph_thumbnail(){ | |
if (is_single()) { | |
echo get_the_post_thumbnail(get_post_id()); | |
} else { | |
echo imagedir() ?>/about_better.png <?php ; | |
} | |
} | |
In WP header.php: | |
<meta property="og:image" content="<?php opengraph_thumbnail(); ?>" /> | |
Output is this: | |
<meta property="og:image" content="" /> | |
:( | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: