/** * HYBRID SCHEMA LOGIC: * 1. If 'custom_schema_payload' exists, output it and DISABLE plugin schema. * 2. If 'custom_schema_payload' is empty, let the plugin handle it normally. */ // Part 1: Output Your Custom Schema (if it exists) add_action('wp_head', function() { if (is_singular()) { // Retrieve the pre-generated schema string $my_schema = get_post_meta(get_the_ID(), 'custom_schema_payload', true); if (!empty($my_schema)) { echo "\n\n"; echo '' . "\n"; } } }, 1); // Part 2: Disable "The SEO Framework" Schema ONLY if Custom Schema exists add_filter('the_seo_framework_json_ld_output', function($default_output) { if (is_singular()) { $my_schema = get_post_meta(get_the_ID(), 'custom_schema_payload', true); // If we found custom schema, shut down the plugin's schema for this page if (!empty($my_schema)) { return false; } } // Otherwise, return true (keep plugin schema active for other pages) return $default_output; });
Skip to content