Support » Fixing WordPress » Previously uploaded attachments is not showing

  • I’m trying to get all attachment of a post in one place and apply the following code from codex. But it’s returning only the newly uploaded attachments not the attachments inserted from media library.

    $args = array(
                    'post_type' => 'attachment',
                    'numberposts' => -1,
                    'post_status' => null,
                    'post_parent' => $post->ID
                $attachments = get_posts( $args );
         if ( $attachments ) {
             echo '<ul>';
             foreach ( $attachments as $attachment ) {
                 echo '<li>';
                 //echo wp_get_attachment_image( $attachment->ID, 'page-img' );
                 echo $attachment->ID;
                 echo '</li>';
             echo '</ul>';

    Thanks in advance.

  • The topic ‘Previously uploaded attachments is not showing’ is closed to new replies.