Guest User

Untitled

a guest
Feb 11th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. function my_attachment_image($postid=0, $size='thumbnail', $attributes='') {
  3. $postid = (isset($postid)) ? $postid : get_the_ID();
  4. $images = get_children(
  5. array(
  6. 'post_parent' => $postid,
  7. 'post_type' => 'attachment',
  8. 'numberposts' => 1,
  9. 'post_mime_type' => 'image'
  10. )
  11. );
  12.  
  13. if (is_array($images)) {
  14. foreach ($images as $image) {
  15. $attachment = wp_get_attachment_image_src($image->ID, $size);
  16.  
  17. echo "<img src=\"{$attachment[0]}\" {$attributes} />";
  18. break;
  19. }
  20. }
  21. }
  22.  
  23.  
  24.  
  25. if ( function_exists('register_sidebar') )
  26. register_sidebar(array(
  27. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  28. 'after_widget' => '</li>',
  29. 'before_title' => '<h2>',
  30. 'after_title' => '</h2>',
  31. ));
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment