Wordpress gallery link to parent-page

Hello everyone,
I need urgent help with a PHP code. I work as a web developer with wordpress and elementor and have now received an order from a customer to include a photo gallery that redirects to the page in which the image is included by clicking on it. I have integrated the gallery, the redirection works already to some extent, but I have the problem that some images do not have a parent ID. Now I have already contacted the wordpress support, they told me that I have to change a php-file to pick out the parent ID automatically. But unfortunately I have no idea about PHP and I don’t know where to insert this code.
Would be very very great if someone could help me!

This is the code I need to implement:

and this is the file where it has to included:

Thank you in advance! :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service