Ready to get started?Download WordPress


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

  1. Gemini23
    Posted 11 months 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…


You must log in to post.

About this Topic