Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

WordPress get_attachement

By: crondeau on Jun 29th, 2011  |  syntax: None  |  size: 0.53 KB  |  views: 113  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         <ul>
  2.         <?php if (have_posts()) : while (have_posts()) : the_post();    
  3.  
  4.                 $args = array(
  5.                         'post_type' => 'attachment',
  6.                         'numberposts' => -1,
  7.                         'post_status' => null,
  8.                         'post_parent' => $post->ID
  9.                 );
  10.                 $attachments = get_posts($args);
  11.                 if ($attachments) {
  12.                         foreach ($attachments as $attachment) {
  13.                                 print "\n";
  14.                                 echo '<li>';
  15.                                 the_attachment_link($attachment->ID, true);
  16.                                 echo '<p>';
  17.                                 echo apply_filters('the_title', $attachment->post_title);
  18.                                 echo '</p></li>';
  19.                         }
  20.                 }
  21.  
  22.          endwhile; endif; ?>
  23.         </ul>
clone this paste RAW Paste Data