Advertisement
Guest User

Untitled

a guest
May 1st, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // Function to get wordpress image attachment
  2. function fetchthumb() {
  3. global $post;
  4. $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
  5. $attachments = get_posts($args);
  6. if ($attachments) :
  7. foreach ( $attachments as $attachment ) {
  8. if( wp_attachment_is_image( empty($attachment->ID) ) )
  9. echo '<img src="'.$scriptpath.'/images/empty.gif" alt="this post has no image" />';
  10. else echo wp_get_attachment_image( $attachment->ID, 'thumbnail');
  11. break;
  12. }
  13. endif;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement