Add role=”status” as status message to a Result Counts Pager facet for screen reader accessibility

<?php
// https://www.w3.org/WAI/WCAG21/Understanding/status-messages.html 
// with a working example at:
// https://www.w3.org/WAI/WCAG22/working-examples/aria-role-status-searchresults/

add_filter( 'facetwp_shortcode_html', function( $output, $atts ) {
  if ( isset( $atts['facet'] ) && 'pager_resultcounts' == $atts['facet'] ) { // Change "pager_resultcounts" to the name of your Pager facet
    $output = str_replace( 'data-name', 'role="status" data-name', $output ); 
  }
  return $output;
}, 10, 2 );