Site logo

Archived topic

Add aria-role to footer widgets

7 replies · Started by Babi on February 22, 2023

Viewing posts 1–8 of 8

According to accessibility audits, the text in GeneratePress footer widgets is not included in an ARIA landmark. As I understand the ARIA guidelines, this would not be the case if the footer widget bar was inside the <footer> tag. But I could alternatively add an ARIA-role attribute to the footer widget bar, as explained here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/contentinfo_role

But I don't know how to do this--I am using a child theme, but I can't find the file that generates the footer widget bar.

Currently the theme has <div id="footer-widgets" class="site footer-widgets">

What I'm after is something like <div id="footer-widgets" class="site footer-widgets" role="contentinfo">

What's the best way to do this?

Well, first of all I can't believe I missed that file--I didn't scroll down far enough, I guess.

But now that I've copied the file into /child-theme/inc/structure and edited the '<div id="footer-widgets"' line, my edits are not shown on the site. Do I misunderstand how the template override works? Is there a better way of accomplishing what I'm after?

Thanks.

I have added the URL and some temporary site credentials to the Private information field.

Hi there,

remove your child theme footer.php and instead use this function:

add_filter( 'generate_parse_attr', function( $attributes, $context ) {
    if ( 'footer-widgets-container' === $context ) {
	$attributes['role'] = "contentinfo";
    }
    return $attributes;
}, 10, 2 );

It will add the role to the container that wraps the widgets.

Brilliant. Thanks very much.

You're welcome

This archived topic is closed to new replies.