Can i have 2 separate Galleries on 2 separate pages each go to a DIFFERENT Attachment.php file?

Every attachment in a gallery has its post_parent set to the ID of the gallery post that it is attached to. So if you have two gallery posts, each with several images, then you can tell which gallery post the attachment is in (in image.php) by examining that post_parent.

So for example, say you had these (numbers are the ID’s of the posts):

  • Gallery Post 1
    • Image post 2
    • Image post 3
    • Image post 4
  • Gallery Post 5
    • Image post 6
    • Image post 7
    • Image post 8

Now, in image.php, you get the $post in the Loop. So if I was looking at Image Post 7, then $post->post_parent would be set to 5. If I was looking at Image post 4, then $post->post_parent would be set to 1.

With that ID, I could do a get_post or something to get the post parent, or I could make a switch-case to do something different depending on the ID, or whatever. How you do it kinda depends on how exactly you’re distinguishing amongst these two different galleries and what it is that you’re displaying or styling differently.