Kirk T
Member
Posted 4 months ago #
Is there a way to automatically redirect links to the attachment page back to the post they are associated with?
I'm using a lightbox effect for galleries, but the problem arises when thumbnail images of a gallery are clicked in an RSS reader. This takes them to the attachment page:
http://thewalters5.com/red-river-gorge-camping-trip/2009/05/rr1/
But, I would rather it take them to the post page to use the lightbox effect and keep all comments on the post instead of individual images:
http://thewalters5.com/red-river-gorge-camping-trip/2009/05/
I've styled the image attachment page for aesthetics sake, but I would prefer they land on the post page.
Any suggestions? Thanks.
Kirk T
Member
Posted 4 months ago #
Just replaced entire attachment page template with this:
<?php wp_redirect(get_permalink($post->post_parent)); ?>
and it seems to do the job.
bekar09
Member
Posted 3 months ago #
can you point the file name exactly?
Kirk T
Member
Posted 3 months ago #
Do you mean redirect to the actual file, or redirect the file somewhere else?
Either way, I'm not sure how...this solution works for me since the RSS links to image files seem to go instead to the attachment page...so redirecting the attachment page to the post page has worked for what I need.
bekar09
Member
Posted 3 months ago #
i mean redirecting the attachment(.jpg) to be redirected to the parent post it is attached to.
Kirk T
Member
Posted 3 months ago #
That's what I thought you meant...sorry I can't help with that...
What's the scenario where you want to do this? Why are people getting to the actual JPG image anyway? There might be another solution depending on the scenario.
bekar09
Member
Posted 2 months ago #
i think you're not getting me. when a visitor searches for an image and reaches my website, i want him to redirect to the post to which the image is attached to.
for example, google image search gives 'image1' the url of which is http://www.my-website.com/path-to-upload-dir/image1.jpg as a result. this 'image1' is attached to 'post1'. when the visitor clicks on that image, it should redirect him to http://www.my-website.com/post1.html.
does that make sense?
Kirk T
Member
Posted 2 months ago #
That makes perfect sense...I definitely see the need for that now...
I'll go back through my notes to see if I ran across any solution for it. I don't remember it, so don't set your hopes too high, but stay tuned...I'll keep you posted.
bekar09
Member
Posted 2 months ago #
waiting for your reply.
tnx,.
Kirk T
Member
Posted 2 months ago #
Well, I didn't find much. This link below seems to be the only one I bookmarked that might lead to some sort of working solution. I didn't really pursue it since my goal was different than yours, but hopefully this will lead to something. Enjoy.
http://www.webmasterworld.com/forum92/6212.htm
bekar09
Member
Posted 2 months ago #
this did'nt help much. anyways thanks.