greater flexibility in targeting images attached to page

Every file that is uploaded in WordPress is an Attachment, which is a kind of post ('post_type' => 'attachment').

When the file is uploaded inside a Post or Page, it is attached to that particular post/page ('post_parent' => $post->ID).
enter image description here

I can think of a solution that doesn’t involves any particular coding:

  • you simply have to put an order in your gallery images ('orderby'=> 'menu_order') and set the number of posts (of the attachment type) to be grabbed as four ('numberposts' => 4).
    enter image description here
    image source

error code: 523