Skip to content

Instantly share code, notes, and snippets.

@norcross
Created November 25, 2014 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norcross/eefc746afb4a2e18bc61 to your computer and use it in GitHub Desktop.
Save norcross/eefc746afb4a2e18bc61 to your computer and use it in GitHub Desktop.
remove the noindex meta tag from single reply comment links
<?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