Get ALL attachments from wordpress


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null );
  3. $attachments = get_posts( $args );
  4. if ($attachments) {
  5. foreach ( $attachments as $post ) {
  6. setup_postdata($post);
  7. the_title();
  8. the_attachment_link($post->ID, false);
  9. the_excerpt();
  10. }
  11. }
  12. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.