Delete role=”navigation” from WordPress theme

Used before category names. Blog WordPress WordPress Development

In new standard of the HTML, for navigation menu, don’t use role=”navigation” anymore. To delete it from the HTML of the WordPress theme, add code below in functions.php file.

//delete role=navigation
add_filter( 'navigation_markup_template', 'hs_navigation_template' );
function hs_navigation_template( $template ) {
    $template = '
    <nav class="navigation %1$s">
        <h2 class="screen-reader-text">%2$s</h2>
        <div class="nav-links">%3$s</div>
    </nav>';

    return $template;
}
Tags: