I have solved. The solution is related with the function get_post_meta();
As WordPress as made by the abstraction of differnet kind of posts with the same structure we can define different post types.
Here we can find more information about the function:
https://developer.wordpress.org/reference/functions/get_post_meta/
And as you can read, you can find 3 vars $post_id, $key and $single.
get_post_meta( int $post_id, string $key = ”, bool $single = false )
The second one, with the $key we can indicate wich post we want to retrive, for default it return data for all keys.
In our case we have a template wiht a portfolio with the key *_swimmingpool_image_gallery** and thats the “key” of our problem.
The full code is here:
$image_gallery = get_post_meta( get_the_ID(), '_swimmingpool_image_gallery', true );
if(!empty($image_gallery)) {
$attachments = array_filter( explode( ',', $image_gallery ) );
$aImage = array();
if ($attachments) {
$i = 0;
foreach ($attachments as $attachment) {
$attachment_url = wp_get_attachment_url($attachment , 'full');
$image = swimmingpool_resize($attachment_url, $slidewidth, $slideheight, true);
if(empty($image)) {$image = $attachment_url;}
$aImage[$i] = $image;
$i++;
}
}
I wish it can help you if you are in the same issue.