attached images

Posted in: Newspaper
Post count: 4

Hello,
To prevent Google from indexing the attached images I added this snippet of code to the fuctions file, but redirect all the images to the home. This code is used for other themes and always works.
/**
* Redirecciona los adjuntos al post padre, o bien, a la portada.
*/
function attachment_redirect()
{
global $post;
if ( is_attachment() )
{
if( $post->post_parent )
wp_redirect( get_permalink($post->post_parent), 301 );
else
wp_redirect( home_url(), 301 );
exit;
}
}
add_action( ‘template_redirect’, ‘attachment_redirect’, 1 );
/**

Post count: 20688

Hi,

You could try some other solutions if that does not work with our theme. This seems to work
https://gist.github.com/ccurtin/6491e5132bc57f6cf979

Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.