WordPress.org

Ready to get started?Download WordPress

Forums

order get_posts attachments from media library (1 post)

  1. Martin
    Member
    Posted 1 year ago #

    Where is the mistake? I'm trying to get all the media from the library (works) and order them in a specific way (doesn't work).

    $args = array(
     'post_type' => 'attachment',
     'numberposts' => -1,
     'post_status' => null,
     'post_parent' => null,
     'orderby' => ID,
     'order' => ASC
     );
    
     $attachments = get_posts($args);
     if ($attachments) {
     foreach ($attachments as $post) {
     setup_postdata($post);
     the_attachment_link($post->ID, false);
     echo '';  }
     }

Topic Closed

This topic has been closed to new replies.

About this Topic