I'm building a custom gallery slider for a Wordpress theme and I have an architecture problem:
While I'm in the post template (single.php) I can easily retrieve an array with all post's galleries images via this code
$galleries = get_post_galleries( $post, false);
(BTW: False parameter is to have theirs url instead of the images themselves)
but when I click on a specific gallery's image, and I'm redirected to the attachment template (attachment.php), then it's impossible to have that same array.
I tried with:
$galleries = get_post_galleries( $post->post_parent, false);
but this doesn't work properly. Indeed if I build a gallery with some pictures which were originally attached to another post (a older one, for example), the post_parent parameter will refer to that old post, instead of the one which redirected me to the attachment template.
Well, this is a problem because my slider script is loaded in the attachement.php and it can't handle the right array of pictures.
I can't trigger it while in single.php because the slideshow start after clicking on a gallery image.
(For the moment I discard the idea of making a more complex script that avoid the loading of attachment.php tempalte).
I'm looking for a workaround to retrive in PHP the right array while in attachment template.