Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of WordPress pagination pseudo-static with html suffix

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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 ('%)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report