-
-
Save mrfoxtalbot/cedb029ba6fa2d4d48e62d06fa5cf8d1 to your computer and use it in GitHub Desktop.
Redireccionar adjuntos al post asociado
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
add_action( 'template_redirect', 'wpsites_attachment_redirect' ); | |
function wpsites_attachment_redirect(){ | |
global $post; | |
if ( is_attachment() && isset($post->post_parent) && is_numeric($post->post_parent) && ($post->post_parent != 0) ) : | |
wp_redirect( get_permalink( $post->post_parent ), 301 ); | |
exit(); | |
wp_reset_postdata(); | |
endif; | |
} | |
// fuente: http://wpsites.net/wordpress-tips/5-ways-to-redirect-attachment-pages-to-the-parent-post-url/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment