×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
0
Language: PHP
Posted by: tarek chida
Added: Dec 13, 2013 2:42 PM
Views: 47
Tags: php wordpress
  1. function getTheFirstImage() {
  2.     $files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
  3.     if($files) :
  4.         $keys = array_reverse(array_keys($files));
  5.         $j=0; $num = $keys[$j];
  6.         $image=wp_get_attachment_image($num, 'large', false);
  7.         $imagepieces = explode('"', $image);
  8.         $imagepath = $imagepieces[1];
  9.         $thumb=wp_get_attachment_thumb_url($num);
  10.          return $thumb;
  11.     endif;
  12. }