This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disables the media attachment page by redirecting the user elsewhere. | |
* Save as 'image.php' in theme. | |
* Inspired by http://www.wpbeginner.com/wp-tutorials/how-to-disable-image-attachment-pages-in-wordpress/ | |
*/ | |
if ($post->post_parent) { | |
wp_redirect(get_permalink($post->post_parent), 301); | |
} else { |