Skip to content

Instantly share code, notes, and snippets.

@gholm
Last active September 19, 2018 08:45
Show Gist options
  • Save gholm/ed070a9c2a197eb301f1df1ca89f897a to your computer and use it in GitHub Desktop.
Save gholm/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;
}
}
@gholm
Copy link
Author

gholm 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