Remove Schema Markup

Home » Snippets » Remove Schema Markup
0

Created with:

Visibility: 

public

Creator: admin@thinkadvanced.com

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
					<?php
// Add a function to the 'the_content' filter
add_filter('the_content', 'wpturbo_remove_course_schema_markup');

function wpturbo_remove_course_schema_markup($content) {
    // Check if the content contains the schema markup with any course code
    $pattern = '/<script type="application/ld+json">.*"@type":s*"Course".*"courseCode":s*"[^"]+".*</script>/isU';
    
    // Perform the regex replacement to remove the script tag with the schema markup for any course
    $content = preg_replace($pattern, '', $content);

    // Return the modified content
    return $content;
}
				

Register an account to save your snippets or go Pro to get more features.