LearnDash: Stop Search Engines Indexing Lessons
Tells search engines not to index LearnDash lessons, topics, quizzes and certificates, which are usually locked and only show a login message to crawlers.
Opens WPIDE on
Code
if ( ! defined( 'LEARNDASH_VERSION' ) ) {
return;
}
add_filter( 'wp_robots', function ( $robots ) {
if ( is_singular( array( 'sfwd-lessons', 'sfwd-topic', 'sfwd-quiz', 'sfwd-certificates' ) ) ) {
$robots['noindex'] = true;
$robots['follow'] = true;
}
return $robots;
} );
Notes
Links on those pages are still followed. Course pages stay indexable.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.