0
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;
}