Skip to content

Instantly share code, notes, and snippets.

Forked from ollietreend/image.php
Created Dec 7, 2016
What would you like to do?
Disable WordPress media attachment page by redirecting to the parent post. Original idea from:
* Disables the media attachment page by redirecting the user elsewhere.
* Save as 'image.php' in theme.
* Inspired by
if ($post->post_parent) {
wp_redirect(get_permalink($post->post_parent), 301);
} else {
wp_redirect(site_url(), 301);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment