Posted By

melvitax on 03/12/08


Tagged

wordpress


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

Wiederkehr
nerdfiles
jwwest
VladNovo
kirichev


Show WordPress Post Attachments


 / Published in: PHP
 

taken from wordpress-- it took me a whole to find this on their site

  1. // place inside loop
  2. $args = array(
  3. 'post_type' => 'attachment',
  4. 'numberposts' => null,
  5. 'post_status' => null,
  6. 'post_parent' => $post->ID
  7. );
  8. $attachments = get_posts($args);
  9. if ($attachments) {
  10. foreach ($attachments as $attachment) {
  11. echo apply_filters('the_title', $attachment->post_title);
  12. the_attachment_link($attachment->ID, false);
  13. }
  14. }

Report this snippet  

You need to login to post a comment.