<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Change meta robots using Yoast SEO
* Credit: Yoast development team
* Last Tested: Jun 19 2017 using Yoast SEO 4.9 on WordPress 4.8
*/
add_filter( 'wpseo_robots', 'yoast_seo_robots_remove_search' );
function yoast_seo_robots_remove_search( $robots ) {
if ( is_search() ) {
return false;
} else {
return $robots;
}
}
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Remove meta robots from Yoast SEO
* Credit: Yoast development team
* Last Tested: Mar 01 2017 using Yoast SEO 4.4 on WordPress 4.7.2
*/
add_filter( 'wpseo_robots', '__return_false' );
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Replace Disallow with Allow Generated Robots.txt
* Credit: Unknown
* Last Tested: Unknown
*/
add_filter('robots_txt','custom_robots');
function custom_robots($output) {
$public = get_option( 'blog_public' );
if ( '0' != $public )
return str_replace('Disallow','Allow',$output);
}