Skip to content

Instantly share code, notes, and snippets.

@JayWood
Created September 30, 2014 22:17
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 JayWood/5dfb4f4dc80c75e8adcf to your computer and use it in GitHub Desktop.
Save JayWood/5dfb4f4dc80c75e8adcf to your computer and use it in GitHub Desktop.
How NOT to get the featured thumbnail src of a WP Post....
<?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