• Resolved jonas18z

    (@jonas18z)


    I want to view all images on a page, I have used this function under but i don’t sort the images if i enter numbers or use the sort function in gallery and i want to use the “medium” size not the full. Is it possible in some way in wordpress?

    <?php
     $args = array(
        'post_type' => 'attachment',
        'numberposts' => -1,
        'post_status' => null,
        'post_parent' => $post->ID
        );
    
    $attachments = get_posts($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
            if(wp_attachment_is_image( $attachment->ID )) {
            echo '<img src="'. wp_get_attachment_url($attachment->ID) . '" alt="gallery" width="600" height="400" />';
            break;
        }
    }
    }
     ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show all images from a post in correct order?’ is closed to new replies.