Created
September 30, 2014 22:17
-
-
Save JayWood/5dfb4f4dc80c75e8adcf to your computer and use it in GitHub Desktop.
How NOT to get the featured thumbnail src of a WP Post....
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
<?php | |
// Featured Image for FB Like | |
$featured_image = get_the_post_thumbnail($post->ID); | |
// Get image source | |
if($featured_image) { | |
$doc = new DOMDocument(); | |
$doc->loadHTML($featured_image); | |
$imageTags = $doc->getElementsByTagName('img'); | |
foreach($imageTags as $tag) { | |
$image_url = $tag->getAttribute('src'); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment