Skip to content

Divi 5: Breadcrumb schema resolves ancestor descriptions via the_content during wp_head, corrupting ET_Builder_Module_Order on child pages #3235

Description

@clichty-fsm

Bug description

On Divi 5 sites with Theme Builder and hierarchical pages, activating AIOSEO Pro causes front-end layout corruption on child pages: et_pb_section_* classes receive CSS rules intended for other sections (e.g. hero backgrounds applied to body sections). The Divi Visual Builder preview is unaffected. Deactivating AIOSEO Pro restores correct rendering on the next request.

Environment

Component Version
WordPress 7.x
Divi 5.8+
AIOSEO Pro 4.9.9
PHP 8.1+
Theme Builder Yes (header/body/footer templates)
Page structure Hierarchical (post_parent chain, 2+ levels)

Minimal reproduction

  1. Create a 3-level page hierarchy built with Divi 5, e.g. /services//services/patients//services/patients/billing/.
  2. Leave ancestor pages without a post_excerpt.
  3. Under Search Appearance → Content Types → Pages, set Meta Description to #post_excerpt (default-adjacent configuration).
  4. Leave schema markup enabled (default).
  5. Load the deepest child page on the front end.

Expected: Front-end output matches Visual Builder.

Actual: Section index CSS is wrong; disabling AIOSEO Pro fixes it immediately.

Observed symptom

Per-page dynamic CSS targets the wrong section index, e.g. et_pb_section_7 receives background rules that belong to a hero section defined elsewhere in the layout.

Call path (confirmed)

During wp_head, schema output triggers breadcrumb context assembly before the main query renders page body content:

  1. AIOSEO\Plugin\Common\Main\Head::wpHead()schema.php
  2. Schema::get()determineSmartGraphsAndContext()Context::post()
  3. Breadcrumb::post()postHierarchical()iterates every ancestor
  4. For each ancestor: Description::getDescription( $post )getPostDescription()
  5. Helpers::sanitize()Tags::replaceTags() with template #post_excerpt
  6. Tags::getTagValue( 'post_excerpt' ) — when post_excerpt is empty, falls through to post_content case
  7. WpContext::getDescriptionFromContent()getPostContent()
  8. PageBuilders\Divi::processContent()renderDivi5ContentForExtraction()
  9. apply_filters( 'the_content', $content ) — runs before main loop / child page render

Relevant source locations:

  • app/Common/Schema/Breadcrumb.phppostHierarchical(), ~L56–76
  • app/Common/Schema/Context.phppost(), ~L103–109
  • app/Common/Utils/Tags.phppost_excerpt / post_content switch fallthrough, ~L1151–1162
  • app/Common/Traits/Helpers/WpContext.phpgetPostContent(), ~L348–372
  • app/Common/Standalone/PageBuilders/Divi.phprenderDivi5ContentForExtraction(), ~L245–257

Root cause

postHierarchical() resolves a full meta description for each ancestor post while building JSON-LD breadcrumb context during wp_head. For Divi-built ancestors without excerpts, description resolution invokes Divi 5 full content rendering (the_content), which increments ET_Builder_Module_Order and generates static CSS keyed by section index.

The main queried object (the child page) then renders with a corrupted module order index, so et_pb_section_N in HTML no longer aligns with the CSS generated for that request.

Regression / partial mitigation note

4.9.9 added ET_Builder_Module_Order::reset_all_indexes() in a finally block after renderDivi5ContentForExtraction() (see comment at Divi.php ~L237–238). This does not appear sufficient when:

  • Multiple ancestors are processed in one wp_head pass, and/or
  • Theme Builder layout types are active on the same request

The issue persists on 4.9.9 with the reset in place.

Ruled out (for triage)

These do not reproduce or resolve the issue in isolation:

  • Changing only the child page excerpt (ancestors still processed in breadcrumb walk)
  • Replacing #post_content with #post_excerpt in page meta template (empty excerpt still falls through to content extraction)
  • Disabling LLMs.txt, Image SEO, TruSEO, or reinstalling the plugin (options persist; trigger is wp_head schema)
  • aioseo_page_builder_integration_disable for divi — only skips VB panel init() in PageBuilders\Base::_init() (~L73); does not gate processContent() used by getPostContent()

Suggested fix

When resolving descriptions for breadcrumb/schema context (especially for posts that are not the main queried object):

  1. Do not call getDescriptionFromContent() / getPostContent() / processContent() for Divi 5 content, or
  2. Use a safe text source only (post_title, non-empty post_excerpt, static template) with no fallthrough to full content rendering, or
  3. Defer breadcrumb description resolution to data that does not invoke the_content on builder content

If content extraction must remain for other features, scope it so renderDivi5ContentForExtraction() never runs during wp_head on front-end singular views, or fully resets Divi 5 static CSS state (including Theme Builder layout scopes) after each extraction pass.

Severity

High for Divi 5 + hierarchical sites: silent visual regression on production, VB shows correct layout, fix requires plugin deactivation or custom workaround. Affects any child page whose ancestors lack excerpts under the default #post_excerpt meta template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions