I wanna redirect all my attachment pages directly to the media file itself instead of showing the attachment page.
Can anybody help me with that?
]]>If not, you have to use something like this (to be put e.g. in you (child) theme’s functions.php)
add_action( 'template_redirect', 'your_prefix_attachment_redirect' );
function your_prefix_attachment_redirect() {
if ( is_attachment() ) {
wp_redirect( wp_get_attachment_url( get_the_ID() ), 301 );
exit();
}
}
]]>