You need to paste code inside the backticks (click the code button above).

I used your gallery.php template (with the fixed anchor) in a test install, and it worked fine. I would guess there is something else in your code, but I see you have changed your link so I cannot look.

I was talking about the code you added in your previous post. You can see the forum has tried to show it and it looks broken.
But that doesn't matter.

I looked at the wrong link when I came back, which is why I thought you have changed the page.

Anyway, the problem is that you do not have http:// in front of your URLs. It looks like WordPress is doing it's best to figure out the URLs, and sometimes getting it right, and sometimes not. Make sure you add http:// in the custom field values and I think it will work.