I would like to create a loop with images per post ID. These are custom images which are made by the theme I’ve bought. These images have a meta_key called “estate_property_images”. This is the code I’ve made, but post with no image are showing images what isn’t possible.
$args = array(
'post_type' => 'attachment',
'orderby' => 'post__in',
'post__in' => get_post_meta( $post->ID, 'estate_property_images', false ));
$gallery_array = get_posts( $args );
foreach ($gallery_array as $slide) {
$attachment = wp_get_attachment_image_src( $slide->ID, 'full' );
$attachment_url = $attachment[0];
$xml .= "\t\t<afbeeldingURL>".$attachment_url."</afbeeldingURL>\n";
}
Can somebody help me fix this problem?