Posted By

fatihturan on 12/10/09


Tagged

post wordpress attachment


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

maxvee8
athanassiadis


Get Attached Images from Post on Wordpress


 / Published in: PHP
 

  1. <?php function postimage($size=thumbnail, $qty=-1) {
  2. if ( $images = get_children(array(
  3. 'post_parent' => get_the_ID(),
  4. 'post_type' => 'attachment',
  5. 'numberposts' => $qty,
  6. 'post_mime_type' => 'image',)))
  7. {
  8. foreach( $images as $image ) {
  9. $attachmenturl=wp_get_attachment_url($image->ID);
  10. $attachmentimage=wp_get_attachment_image( $image->ID, $size );
  11.  
  12. echo '<li><a href="'.$attachmenturl.'" rel="shadowbox[photos]">'.$attachmentimage.'</a></li>' . "\n";
  13. }
  14. } else {
  15. echo "No Image";
  16. }
  17. } ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: tesfayaddise on December 10, 2009

please show me the picture

Posted By: fatihturan on August 30, 2010

Which picture?

You need to login to post a comment.