WordPress-Free Plug-in Implementation article page

Source: Internet
Author: User
Tags extend php file range
Plug-ins too much is always bad, the spirit can not use the principle of online search, this method is feasible.

Plug-ins too much is always bad, the spirit can not use the principle of online search, this method is feasible.
1. Open the functions.php file below wp-includes to insert this code:
Page-free plug-ins add their own
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 "<a href= '". Get_pagenum_link (1). "' class= ' extend ' title= ' jump to Home ' > Back Home </a> ';} Previous_posts_link (' previous page ');
if ($max _page > $range) {if ($paged < $range) {for ($i = 1; $i <= ($range + 1); $i + +) {echo "<a href= '". Get_pagen Um_link ($i). "'";
if ($i = = $paged) echo "class= ' current"; echo > $i </a>;}} ElseIf ($paged >= ($max _page–ceil (($range/2))) {for ($i = $max _page– $range;
$i <= $max _page; $i + +) {echo "<a href= '". Get_pagenum_link ($i). "'";
if ($i = = $paged) echo "class= ' current"; echo > $i </a>;}} ElseIf ($paged >= $range && $paged < ($max _page–ceil (($range/2))) {for ($i = ($paged –ceil ($range/2));
$i <= ($paged + ceil ($range/2)); $i + +) {echo "<a href= '". Get_pagenum_link ($i). "'";
if ($i = = $paged) echo "class= ' current"; echo > $i </a> ";}}} Else{for ($i = 1;
$i <= $max _page; $i + +) {echo "<a href= '". Get_pagenum_link ($i). "'";
if ($i = = $paged) echo "class= ' current"; echo > $i </a>;}} Next_posts_link (' next page ');
if ($paged!= $max _page) {echo "<a href= '". Get_pagenum_link ($max _page). "' class= ' extend ' title= ' jumps to last page ' > last page </a> ';} }
2. In the theme directory to find the index.php,search.php,archive.php of the three files, the theme is different, of course, the name is not necessarily the same, find the home page, search page, paging the three files on the line, and then add <div><?php par_ Pagenavi (4)?></div> to the original paging code, which is to replace the paging code <div>
<div><?php Previous_comments_link ()?></div>
<div><?php Next_comments_link ()?></div>
</div>
3. Add the style code to the 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;}
This article Sky (www.zzjs.net) original editor, please observe the industry rules, reprint reserved copyright.



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.