Turn Off Yoast Schema on Selected Pages
Removes the Yoast SEO JSON-LD graph from the pages you list, for example landing pages where you print your own structured data.
Opens WPIDE on
Code
// IDs of the posts or pages that should not get Yoast's schema.
$wpide_no_schema_ids = array( 12, 34 );
add_filter( 'wpseo_json_ld_output', function ( $output ) use ( $wpide_no_schema_ids ) {
if ( is_singular() && in_array( get_queried_object_id(), array_map( 'intval', $wpide_no_schema_ids ), true ) ) {
return false;
}
return $output;
} );
Notes
List page or post IDs in $wpide_no_schema_ids. Yoast's other meta tags still print.
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.