ucsc / ucsc-2022

Official WordPress theme for UC Santa Cruz
6 stars 0 forks source link

Site title block modification generates broken HTML #299

Closed knice closed 4 months ago

knice commented 4 months ago

Background

All web pages should have one and only one h1 tag, which indicates the beginning of the heading hierarchy for the page. In order to have a proper headline tag hierarchy on our sites, we make sure the core/site-title block is an h1 tag on the site's home page. That means no matter what the block's actual setting is, we need to make it an h1 on the home page. On internal pages, the core/site-title block should be a paragraph tag, because the core/page-title or core/post-title block is the h1.

Issue

In our functions.php file, on line 160, we're filtering the core/site-title block to make the change described above. However, the code only changes the first instance of the tag, leaving the closing tag untouched. That means on every home page, we creating broken HTML, such as <h1>[...]</p>. The string replace function is only replacing the opening tag and not the closing tag.

screenshot-2024-02-24-101116