Skip to content

Instantly share code, notes, and snippets.

@spidirs
Last active September 19, 2018 08:45
Show Gist options
  • Select an option

  • Save spidirs/ed070a9c2a197eb301f1df1ca89f897a to your computer and use it in GitHub Desktop.

Select an option

Save spidirs/ed070a9c2a197eb301f1df1ca89f897a to your computer and use it in GitHub Desktop.
Remove meta robots, like "noindex" and "nofollow" for the 404 template, from Yoast SEO
/********* remove 'noindex' from 404 pages *********/
/* Based on this snippet:
* https://gist.github.com/amboutwe/0c71e42aa164238007d7ea88f174a93f#file-yoast_seo_robots_remove_search-php
*/
add_filter( 'wpseo_robots', 'yoast_seo_robots_remove_404' );
function yoast_seo_robots_remove_404( $robots ) {
if ( is_404() ) {
return false;
} else {
return $robots;
}
}
@spidirs
Copy link
Author

spidirs commented Sep 18, 2018

This goes in functions.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment