Session Overview

This session (spanning two Cowork conversations due to context limits) addressed a sitewide issue where Rank Math FAQ blocks stopped rendering across approximately 148 pages and posts on aguiarinjurylawyers.com. The root cause was a chain of WPCode snippet operations that stripped JSON attributes from Rank Math FAQ block comments in the WordPress database. The session also included cleanup of 9+ obsolete WPCode snippets created during the debugging and fix process.

Sam's original requests were:

  1. Fix FAQ rendering sitewide
  2. Delete the "Fix Encoded HTML" snippet and the "Add Missing H1 Tags" snippet from WPCode
  3. No H1 functionality needed from code snippets

Root Cause Chain

The root cause was a chain reaction across multiple WPCode snippets:

Step 1: Snippet 40203 ("Add Missing H1 Tags") used wp_update_post() to insert H1 tags into pages. WordPress's wp_update_post() internally calls wp_slash() then wp_unslash(), which stripped backslashes from the post content. This turned JSON unicode escapes like \u003c (which Rank Math FAQ blocks use to encode HTML inside block comment JSON) into literal u003c text.

Step 2: Snippet 40248 ("Fix Encoded HTML") was created to fix the u003c/u003e rendering issue. It used $wpdb->query() to do a direct SQL replace of u003c back to < and u003e back to >. However, this operation also affected the block comment JSON, stripping the JSON attributes from Rank Math FAQ block comments entirely.

Step 3: With no JSON in the block comments (e.g., <!-- wp:rank-math/faq-block --> instead of <!-- wp:rank-math/faq-block {"questions":[...]} -->), the Rank Math render_callback had no data to render, so FAQ sections disappeared sitewide.


What Was Accomplished

Fix Confirmed Working

Snippet 40306 ("Bulk Fix FAQ JSON + Gradient v2") had already been created and run during the first session. It rebuilt the JSON attributes for all affected FAQ blocks using eval(base64_decode(...)) to avoid WPCode's character mangling of \u003c escapes. This snippet used a get_option('faq_rebuild_v2_done') guard so it only ran once.

The fix was confirmed working. All FAQ blocks now have proper JSON in their block comments with \u003c encoding and unique question IDs in the format faq-question-{post_id}-{index}.

Frontend Verification

FAQ rendering confirmed on three pages: