Example Analysis of WordPress pagination pseudo-static with html suffix
This article will explain in detail the example analysis of WordPress pagination pseudo-static plus html suffix. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Ugly
Adding a / and a number to the static file .html is simply confusing, which is only secondary. The important thing is that I found that search engines do not include such strange links at all, which is really unacceptable. What I write is very important at the beginning and end, and can't be ignored just because it's page by page.
Not included
Take this article, search for the first page of the article, Google included:
Search for the content on the second and third pages of the article, but it is not included at all:
Solution
So I decided on the link generation and parsing rules for DIY WordPress.
Train of thought
Use filter wp_link_pages_link to rewrite the paged link / 123456 as page- [123456] .html.
Restore page- [123456] .html to / 123456 using WordPress or server RewriteRule
Add hook redirect_canonical to prevent WordPress from forcibly jumping from page- [123456] .html to / 123456.
Generate paged html suffix links
Add to the WordPress theme:
Class Rewrite_Inner_Page_Links {var $separator; var $post_rule; function _ _ construct () {$this- > separator ='/ page-'; / / (. +?) / ([^ /] +). Html (/ [0-9] +)? /? $this- > post_rule ='(. +?) / ([^ /] +) ('. $this- > separator. '([0-9] +)) + .html /? $'; if (! is_admin () | defined ('DOING_AJAX')): add_filter (' wp_link_pages_link', array ($this, 'inner_page_link_format'), 10, 2); / / for inner pages add_filter (' redirect_canonical', array ($this, 'cancel_redirect_for_paged_posts'), 10, 2); endif If (is_admin ()): add_filter ('rewrite_rules_array', array ($this,' pagelink_rewrite_rules')); endif;} / * * modify the format of the post paging link * @ param string $link * @ param int $number * @ return string * / function inner_page_link_format ($link, $number) {if ($number > 1) {if (preg_match ('%)