Static wordpress article list page by page, adding html suffix

Source: Internet
Author: User
: This article mainly introduces the page-based static wordpress list and adds html suffixes. For more information about PHP tutorials, see. First View Results

After use, the URL is http: // localhost/news/paged/1.html.

1. HTML suffix

Add_filter ('Get _ pagenum_link ', 'My _ get_pagenum_link', 1, 1 );

Function my_get_pagenum_link ($ url)
{
Return str_replace('.html ', '', URL extension .'.html ';
}

2. add rewrite rules

If (! Is_admin () // only front-end page Applications

{

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 enables the slug to be 'new'.

Add_rewrite_rule ('(.*)? /Paged /(.*)?. Html $ ', 'index. php? P = $ matches [1] & page = $ matches [2] ', 'top'); // applies to all types

}

Note: the regular expression may change according to your actual situation.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces static pages of The wordpress article list, adding html suffixes, including content, and hope to be helpful to friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.