Wordpress PHP page Code _php Tutorial

Source: Internet
Author: User
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; ....

  • 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.