<?php
// Add <p role="status" id="resultsmsg"></p> to your page
// The following snippet will add "# results returned" to the text of this <p> element on facet refresh.
// 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_action( 'facetwp_scripts', function() {
?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
let total_results = FWP.settings.pager.total_rows;
let resultsmsg = total_results + ' results returned';
let resultsElement = document.getElementById('resultsmsg');
resultsElement.innerHTML = resultsmsg;
});
})(fUtil);
</script>
<?php } );