Skip to content

Instantly share code, notes, and snippets.

@visualpropaganda
Created May 9, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save visualpropaganda/4edfb934eab30024219f045808f9dbc5 to your computer and use it in GitHub Desktop.
Save visualpropaganda/4edfb934eab30024219f045808f9dbc5 to your computer and use it in GitHub Desktop.
Disable Image Attachment Pages Using A WP Redirect
<?php
global $post;
if ( $post && $post->post_parent ) {
wp_redirect( get_permalink( $post->post_parent ), 301 );
exit;
} else {
wp_redirect( home_url( '/' ), 301 );
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment