See the effect first
After use, the link address is: http://localhost/news/paged/1.html
1. Add a filter and use the link address to add the .html suffix
add_filter( 'get_pagenum_link' ,'my_get_pagenum_link' ,1 ,1 );
function my_get_pagenum_link( $url )
{
return str_replace('.html', '', $url).'.html';
}
2. Add repeat Write rules
if( !is_admin() ) //Only front-end page application
{
add_action('init' , 'my_post_rewrite' );
}
function my_ post_rewrite()
{
global $wp_rewrite;
add_rewrite_rule('news/paged/(.*)?.html$' , 'index.php?p=news&page=$matches[2]','top' ); //Only for The activation function of category slug is 'news'
add_rewrite_rule('(.*)?/paged/(.*)?.html$' , 'index.php?p=$matches[1]&page=$matches[2 ]','top' ); //Applies to all categories
}
Note: The expression may change according to your actual situation
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces the static pagination of WordPress article list, adding the html suffix, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.