Last active
December 30, 2015 09:29
-
-
Save annalinneajohansson/7809276 to your computer and use it in GitHub Desktop.
Do not index attachment pages in WordPress
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 | |
/* | |
Plugin Name: Hippies attachments noindex | |
Plugin URI: | |
Description: Do not index attachment pages and set default image link type to "none" on plugin activation. | |
Version: 1 | |
Author: Hippies | |
Author URI: http://hippies.se/ | |
*/ | |
add_action( 'wp_head', 'hip_attachments_noindex_wp_head' ); | |
function hip_attachments_noindex_wp_head() { | |
if( is_attachment() ) { | |
echo '<meta name="robots" content="noindex, follow">'; | |
} | |
} | |
function hip_attachments_noindex_activate() { | |
update_option( 'image_default_link_type', 'none' ); | |
} | |
register_activation_hook( __FILE__, 'hip_attachments_noindex_activate' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment