Fix heading-order in WordPress
WordPress sites often violate heading-order when sidebar widget titles default to <h4> or <h5>, or when authors pick an <h4> Gutenberg Heading block inside a post because <h2> looks too large. Changing widget wrappers in register_sidebar() to <h2> with a visual class and pairing semantic Gutenberg levels with typography presets fixes every post and archive cleanly.
Before and after
<?php // functions.php (Broken: sidebar widget titles jump directly to <h4>)
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'mytheme' ),
'id' => 'sidebar-1',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );<?php // functions.php (Fixed: semantic <h2> styled visually via CSS utility class)
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'mytheme' ),
'id' => 'sidebar-1',
'before_title' => '<h2 class="widget-title text-sm font-semibold">',
'after_title' => '</h2>',
) );Fixed vs. broken example
Decouple visual typography from semantic heading depth: choose <h1>–<h6> strictly for document outline nesting and apply CSS utility classes for font size.
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("WordPress single post & sidebar follow sequential heading-order", async ({ page }) => {
await page.goto("/blog/wcag-2-2-checklist/");
const results = await new AxeBuilder({ page })
.withRules(["heading-order"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
A before_title => '<h4 class="widget-title">' declaration in functions.php triggers heading-order across every WordPress blog post and archive. Updating that one register_sidebar() call resolves every URL at once.
What NVDA and VoiceOver announce
Over 67% of screen-reader users navigate long pages primarily by jumping between headings (H / 1–6 keys). Skipping from <h1> straight to <h4> for visual sizing breaks the mental document outline and makes sub-sections appear orphaned.
NVDA (Windows)
"Accessibility Audit Report, heading level 1" -> "Key Template Clusters, heading level 4" (user suspects missed sections 2 & 3)
"Accessibility Audit Report, heading level 1" -> "Key Template Clusters, heading level 2"
VoiceOver (macOS / iOS)
"heading level 1, Accessibility Audit Report" -> "heading level 4, Key Template Clusters"
"heading level 1, Accessibility Audit Report" -> "heading level 2, Key Template Clusters"
Common questions
How do I change font size in a Gutenberg Heading block without picking H4?
Should a WordPress post's 'Related Posts' or 'Leave a Reply' heading be an H2?
Can a WordPress site use multiple <h2> and <h3> headings on one page?
Test a URL for heading-order
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Managing WordPress client sites? Monitor 15 sites on one flat plan with white-label portals and branded executive PDFs—$1,140/yr ($95/mo billed annually, 24-month rate lock + onboarding) for Founding 10 agencies.