• Resolved Slavek

    (@jackoneill)


    While preparing a course, I want to noindex lessons and quizzes with the Yoast SEO plugin. But it seems it’s not working. Clicking the tabs (for some reason grayed out https://pasteboard.co/eZdyH8Roe1Uo.jpg) in Yoast, the URL is not changing, getting only …/wp-admin/admin.php?page=wpseo_page_settings#/post-type/lesson, no matter if I click lessons, quizzes or assignments. Even though “Show POST TYPE in search results” and “Show the archive for POST TYPE in search results” are disabled, they appear in the sitemap: …/lesson-sitemap.xml and …/tutor_quiz-sitemap.xml.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @jackoneill,

    Thank you for reaching out to us with your issue regarding noindexing lessons and quizzes using the Yoast SEO plugin. We understand how important it is to have control over your site’s SEO settings.

    It appears that the Yoast SEO settings for custom post types, such as lessons and quizzes, are not functioning as expected. This can sometimes happen due to compatibility issues between plugins. To resolve this issue, you can add custom code to your theme’s functions.php file.

    Here is a the code :

    // Function to set noindex for lessons and quizzes
    function noindex_tutor_lms_lesson_and_quiz( $robots ) {
    if ( is_singular('lesson') || is_singular('tutor_quiz') ) {
    return 'noindex, nofollow';
    } else {
    return $robots;
    }
    }
    add_filter( 'wpseo_robots', 'noindex_tutor_lms_lesson_and_quiz' );

    // Function to remove lessons and quizzes from Yoast sitemap
    function remove_lesson_and_quiz_from_sitemap( $value, $post_type ) {
    $post_type_to_exclude = array('lesson','tutor_quiz');
    if( in_array( $post_type, $post_type_to_exclude ) ) return true;
    }
    add_filter( 'wpseo_sitemap_exclude_post_type', 'remove_lesson_and_quiz_from_sitemap', 10, 2 );

    After adding this code, the lessons and quizzes should be set to noindex and should no longer appear in the Yoast SEO sitemap.

    If you continue to experience issues or have any other questions, please feel free to let us know. We are here to help!

    Best regards,
    Mohammad Nafiz

    Thread Starter Slavek

    (@jackoneill)

    Thank you, Mohammad, this works.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Lessons & Quizzes: how to noindex and remove from sitemap with Yoast SEO?’ is closed to new replies.