Here's the deal: I was migrating the content (lots of posts) from an old site to a new one. The posts have multiple images attached to it (which I've noticed when I was importing the thumbnail images via WP All Import) and it is being nicely displayed in single.php template like this:
Main image
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_array->ID), 'full'); ?>
+ HTML markup
Little thumbnails beneath main image (if there are more than one images)
$images = sql_post_images( $ID = get_the_ID(), get_post_thumbnail_id( $ID ) );
foreach($images as $image) {
HTML markup
}
sql_post_images() function
function sql_post_images( $post_id, $exclude_id = 0 ) {
global $wpdb;
$data = $wpdb->get_results(
$wpdb->prepare(
"
SELECT DISTINCT wposts.ID,
wposts.post_title,
wposts.post_excerpt,
wposts.post_content,
wpostmeta.meta_value
FROM $wpdb->posts wposts
LEFT JOIN $wpdb->postmeta wpostmeta
ON wpostmeta.post_id = wposts.ID
AND wpostmeta.meta_key = %s
WHERE wposts.post_parent = %d
AND wposts.post_type = 'attachment'
AND (wposts.post_mime_type = 'image/jpeg' OR wposts.post_mime_type = 'image/png' OR wposts.post_mime_type = 'image/gif')
AND wposts.ID != %d
ORDER BY wposts.menu_order ASC
", '_wp_attachment_metadata', $post_id, $exclude_id), ARRAY_A);
return( $data );
}
This works well and I would like to keep it like that in the future as well - the problem is I cannot find a solution to allow upload of multiple images to a post. I found some plugins, but their approach is clearly different (it's either just a second thumbnail image, or something similar). What could actually work?
EDIT: Uploading images as a classic WP attachments doesn't seem to do the trick.