There’s a couple issues.
1) You’re not supposed to put HTML inside most translations strings ( such as this ).
2) The screen_reader_text
argument does not accept HTML at all, you need to filter the HTML by using the following hook:
navigation_markup_template
– Filters the navigation markup template.
/**
* Modify the given HTML
*
* @param String $template - Comment Pagination Template HTML
* @param String $class - Passed HTML Class Attribute
*
* @return String $template - Return Modified HTML
*/
function change_reader_heading( $template, $class ) {
if( ! empty( $class ) && false !== strpos( $class, 'comments-pagination' ) ) {
$template = str_replace( '<h2', '<h3', $template );
}
return $template;
}
add_filter( 'navigation_markup_template', 'change_reader_heading', 10, 2 );
The above searches the $template
HTML string and replaces all h2
tags with h3
tags.