Created
November 25, 2014 03:38
-
-
Save norcross/eefc746afb4a2e18bc61 to your computer and use it in GitHub Desktop.
remove the noindex meta tag from single reply comment links
This file contains hidden or 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 | |
add_action( 'init', 'rkv_comment_noindex_base' ); | |
/** | |
* remove the noindex flag on the reply links | |
* when not using Yoast SEO | |
* | |
* @return null | |
*/ | |
function rkv_comment_noindex_base() { | |
if ( isset( $_GET['replytocom'] ) ) { | |
remove_action( 'wp_head', 'wp_no_robots' ); | |
} | |
} | |
add_filter( 'wpseo_robots', 'rkv_comment_noindex_yoast' ); | |
/** | |
* remove the meta index tag for replyto | |
* links when Yoast SEO is active | |
* | |
* @param [string] $robotsstr the current string | |
* @return null | |
*/ | |
function rkv_comment_noindex_yoast( $robotsstr ) { | |
// bail without Yoast | |
if ( ! class_exists( 'WPSEO_Frontend' ) ) { | |
return $robotsstr; | |
} | |
// bail without that query string | |
if ( ! isset( $_GET['replytocom'] ) ) { | |
return $robotsstr; | |
} | |
// return false to remove the tag | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment