如何删除h2
屏幕阅读器文本中使用的标记?我使用以下$args
, 但h2仍然存在:
the_comments_pagination( array(
\'add_fragment\' => \'\',
\'screen_reader_text\' => __( \'<h3>Test</h3>\' )
) );
如何删除h2
屏幕阅读器文本中使用的标记?我使用以下$args
, 但h2仍然存在:
the_comments_pagination( array(
\'add_fragment\' => \'\',
\'screen_reader_text\' => __( \'<h3>Test</h3>\' )
) );
有几个问题。
1) 你不应该把HTML放在大多数翻译字符串中(比如这个)。
2) Thescreen_reader_text
参数根本不接受HTML,您需要使用以下挂钩过滤HTML:
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 );
以上搜索$template
HTML字符串并替换所有h2
标记为h3
标签。目前,我的分页页面URL为:http://www.example.com/category_name/page/2但我需要将此URL结构更改为:http://www.example.com/category_name/?page=2等有什么解决方案吗?