<?php /** * Plugin Name: Rank Math Meta Fix * Description: Sets correct meta titles and descriptions using output buffering * Version: 1.2 // EDIT TEST */ add_action('template_redirect', 'rm_meta_ob_start', 0); function rm_meta_ob_start() { // Only buffer for pages and single posts we need to fix if (is_page([299, 1587, 1173, 1174]) || is_single([2049, 2046, 1909, 1906])) { ob_start('rm_meta_fix_buffer'); } } function rm_meta_fix_buffer($html) { $overrides = [ 299 => ['title' => 'Water Damage Tips & Guides California - FixWater CA Blog', 'desc' => 'Expert tips and guides for water damage prevention, detection, and recovery in California. Learn about flooded basements, hardwood floors, drywall damage, and more.'], 1587 => ['title' => 'About FixWater CA - Water Damage Restoration Referral Service', 'desc' => 'FixWater CA connects California homeowners with licensed water damage restoration professionals. Learn about our free referral service across LA, Orange, Ventura counties.'], 1173 => ['title' => 'Terms and Conditions - FixWater CA Water Damage Referral', 'desc' => 'Terms and conditions for FixWater CA. Learn about our free water damage restoration referral service, disclaimers, and how we connect you with local professionals.'], 1174 => ['title' => 'Privacy Policy - FixWater CA Water Damage Restoration', 'desc' => 'FixWater CA privacy policy. Learn how we collect, use, and protect your personal information when you use our water damage restoration referral service.'], 2049 => ['title' => 'Water Damaged Kitchen Cabinets Repair CA 2026', 'desc' => 'Learn how to assess, salvage, or replace water damaged kitchen cabinets in California. Expert tips for drying, mold prevention, and restoration costs.'], 2046 => ['title' => 'Flooded Basement California Causes & Prevention', 'desc' => 'Discover the top causes of basement flooding in California, prevention tips, and professional recovery steps to protect your property from water damage.'], 1909 => ['title' => 'Ceiling Water Damage Stain Repair CA Guide 2026', 'desc' => 'Learn how to identify, assess, and repair ceiling water damage stains in California. Expert guide on water damage restoration and stain removal costs.'], 1906 => ['title' => 'Drywall Water Damage Repair California Guide 2026', 'desc' => 'Complete guide to drywall water damage repair in California. Learn when to patch vs replace, mold prevention, and professional restoration costs.'], ]; global $post; if (!$post || !isset($overrides[$post->ID])) return $html; $title = $overrides[$post->ID]['title']; $desc = $overrides[$post->ID]['desc']; // Debug: add a comment to verify buffer is running $html .= "\n<!-- RM_META_FIX: Applied for post ID " . $post->ID . " -->\n"; // Replace title tag $html = preg_replace('/<title>.*?<\/title>/is', '<title>' . htmlspecialchars($title, ENT_QUOTES) . '</title>', $html, 1); // Replace meta description $html = preg_replace('/<meta[^>]*name="description"[^>]*content="[^"]*"[^>]*\/?>/is', '<meta name="description" content="' . htmlspecialchars($desc, ENT_QUOTES) . '" />', $html, 1); // Replace og:title $html = preg_replace('/<meta[^>]*property="og:title"[^>]*content="[^"]*"[^>]*\/?>/is', '<meta property="og:title" content="' . htmlspecialchars($title, ENT_QUOTES) . '" />', $html, 1); // Replace og:description $html = preg_replace('/<meta[^>]*property="og:description"[^>]*content="[^"]*"[^>]*\/?>/is', '<meta property="og:description" content="' . htmlspecialchars($desc, ENT_QUOTES) . '" />', $html, 1); return $html; } https://fixwaterca.com/post-sitemap.xml 2026-04-19T07:24:04+00:00 https://fixwaterca.com/page-sitemap.xml 2026-04-18T16:23:25+00:00 https://fixwaterca.com/category-sitemap.xml 2026-04-19T07:24:04+00:00