1

I have a WordPress website that is using the Twenty Twenty-Two block theme (more specifically, a child theme of it). I want to edit the <html> root HTML element to add an attribute. I want this line of code:

<html lang="en-US">

... to change into this line of code:

<html lang="en-US" foo="bar">

Since this a block theme, there is no header.php file to edit. How do I do this?

1 Answer 1

2

It's possible to use the language_attributes filter as before since the template canvas in FSE contains:

<html <?php language_attributes(); ?>>

Add this code to the appropriate place in your theme or plugin:

<?php
add_filter( 'language_attributes', function($lang_attributes) {
    return "$lang_attributes foo=\"bar\"";
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.