How to redirect image attachment urls to parent post? (1 post)

  1. Gemini23
    Posted 1 year ago #

    I have seen this question asked before but cannot see an answer that works...

    I would like my image attachment urls to redirect to their parent posts…

    I have tried:

    1) adding this to the first line of image.php but it doesn’t work at all

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

    2) I have added attachment redirect plugin but that just redirects everything to the homepage.

    So... Please can someone advise how I can get image attachments to redirect to their parent posts…

Topic Closed

This topic has been closed to new replies.

About this Topic