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.