YoastSEO Schema Disable for Custom Post Types

This issue still persists and I had to create a function to resolve this:

add_filter( 'wpseo_json_ld_output', 'disable_yoast_schema_for_specific_post_types', 10, 1 );

function disable_yoast_schema_for_specific_post_types( $data ) {
    // List of post types where you want to disable Yoast schema
    $disabled_post_types = array( 'post', 'page' ); // Add or remove post types as needed

    // Check if we're on a singular post/page and if the current post type is in our disabled list
    if ( is_singular() && in_array( get_post_type(), $disabled_post_types ) ) {
        return false; // This will disable the schema output
    }

    return $data; // Return the original data for other post types
}
  • This topic was modified 5 hours, 38 minutes ago by lsmedia.

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer