WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Gemini23
    Member
    Posted 4 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…

Reply

You must log in to post.

About this Topic