Wordpress plug-free implementation article page_php tutorial

Source: Internet
Author: User
Wordpress plug-in-free for pagination of articles. Too many plug-ins are always bad. in line with the principle that you don't need them, you can find them online. this method is feasible. 1. open the functions. php file under wp-uplodes and insert this code: too many plug-ins are always bad. in line with the principle that you don't need it, you can find it online. this method is feasible.
1. open the functions. php file under wp-uplodes and insert this code:
// Page-based plug-in-free self-added
Function par_pagenavi ($ range = 4 ){
Global $ paged, $ wp_query;
If (! $ Max_page) {$ max_page = $ wp_query-> max_num_pages;} if ($ max_page> 1) {if (! $ Paged) {$ paged = 1;} if ($ paged! = 1) {echo "back to home";} previus_posts_link ('previous page ');
If ($ max_page> $ range) {if ($ paged <$ range) {for ($ I = 1; $ I <= ($ range + 1 ); $ I ++) {echo "if ($ I = $ paged) echo" class = 'current' "; echo"> $ I ";}} elseif ($ paged >=( $ max_page-ceil ($ range/2) {for ($ I = $ max_page-$ range;
$ I <= $ max_page; $ I ++) {echo "if ($ I = $ paged) echo" class = 'stream '"; echo "> $ I" ;}} elseif ($ paged >=$ range & $ paged <($ max_page-ceil ($ range/2 )))) {for ($ I = ($ paged-ceil ($ range/2 ));
$ I <= ($ paged + ceil ($ range/2); $ I ++) {echo "if ($ I = $ paged) echo "class = 'current'"; echo "> $ I" ;}} else {for ($ I = 1;
$ I <= $ max_page; $ I ++) {echo "if ($ I = $ paged) echo" class = 'stream '"; echo "> $ I" ;}} next_posts_link ('next page ');
If ($ paged! = $ Max_page) {echo "Last Page ";}}}
2. locate index in the topic directory. php, search. php, archive. php files have different themes, but the names are not necessarily the same. you just need to find the home page, search for pages, flip the pages, and then add

To the original paging code, that is, to replace this paging code





3.parse sample code to style.css.
. Page_navi {width: 100%; height: 36px; line-height: 36px; text-align: center; overflow: hidden; padding-top: 1em ;}
. Page_navi a {padding: 3px 8px; margin: 2px; text-decoration: none; color: #888; border: 1px solid # ccf ;}
. Page_navi a: hover,. page_navi a. current {border: 1px solid #356aa0; color: #356aa0; font-weight: bolder ;}

Bytes. 1. open the functions. php file under wp-uplodes and insert this code: // points...

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.