Forums

[resolved] Attachment page Redirect to Post page - How To? (2 posts)

  1. Kirk T
    Member
    Posted 5 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.

  2. Kirk T
    Member
    Posted 2 months ago #

    Found this solution a while back:

    Make an image or attachment page template with the following line:

    <?php wp_redirect(get_permalink($post->post_parent)); ?>

Reply

You must log in to post.

About this Topic