Effect:
Put the following function in the functions.php file of your topic:
Copy CodeThe code is as follows:
function Theme_echo_pagenavi () {
Global $request, $posts _per_page, $wpdb, $paged;
$maxButtonCount = 9; Maximum number of links displayed
if (!is_single ()) {
if (!is_category ()) {
Preg_match (' #FROM \s (. *) \sorder By#siu ', $request, $matches);
} else {
Preg_match (' #FROM \s (. *) \sgroup By#siu ', $request, $matches);
}
$fromwhere = $matches [1];
$numposts = $wpdb->get_var ("Select COUNT (DISTINCT ID) from $fromwhere");
$max _page = ceil ($numposts/$posts _per_page);
if (empty ($paged)) {
$paged = 1;
}
$start = max (1, $paged-intval ($maxButtonCount/2));
$end = min ($start + $maxButtonCount-1, $max _page);
$start = max (1, $end-$maxButtonCount + 1);
if ($paged = = 1) {
echo "Home Page";
echo "Previous Page";
}else{
Echo 'Home Page';
Echo 'Previous Page';
}
for ($i = $start; $i <= $end; $i + +) {
if ($i = = $paged) {
echo "[$i]";
} else {
Echo '['. $i. ']';
}
}
if ($paged = = $max _page) {
echo "Next Page";
echo "last page";
}else{
Echo 'Next Page';
Echo 'last page';
}
echo "{$numposts} records, {$max _page} page.";
}
}
This is referred to in the subject's index.php file:
Copy CodeThe code is as follows:
http://www.bkjia.com/PHPjc/320770.html www.bkjia.com true http://www.bkjia.com/PHPjc/320770.html techarticle Effect: Place the following function in the functions.php file of your theme: Copy the code as follows: function Theme_echo_pagenavi () {global $request, $posts _per_page, $WP DB, $paged; ....