I want to reuse featured images for new posts. So a single featured image from the media library is attached to more than one post. When i use post_parent ); ?> on the attachment page to go back to the post, the user will be redirected to the first post the image was attached.

How can i redirect the user to the actual post the user comes from?

1 Answer 1


You might use $_SERVER['HTTP_REFERER'] but take in mind that is not always sent so check for its existence and think about a fallback!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.