Subnavigation
Front Page
Displays posts from every section of the site on one page.
Blog
Only show blog posts.
Archive
List of all posts for quick browsing.
Hosting
- Anything is appreciated, even a dollar can cover my hosting costs for a while, depending on bandwidth usage.
Recent Comments
Gordo on Moved to a new server...
Brett on Moved to a new server...
Gordo on Legalizing Recreational Drugs
Gordo on Gulf
Gordo on Oak Mtn Beach
RSS Feeds
Friends
Henry B. Rosenbush
Matt Friel
Locust Fork Journal
Jimmy Cantrell
Jamie Smith
IT Pros on the Go
Film Guys
Paul ChaterI hate Wordpress
Posted on Friday, January 23, 2009 at 01:38:21 PM.Upgraded a client to Wordpress 2.7 and the pagination went missing.
I started echoing out all of the variables until I found out that $max_page was null.
Open wp-includes/link-template.php.
Look for the "get_next_posts_link" function and for the following line:
$max_page = $wp_query->max_num_pages;
I did a print_r() of $wp_query and found that "max_num_pages" was NULL. I tried going up-stream from there into the database code to look for any bugs but wasn't able to find any. I double-checked the database to make sure max_num_pages was set, and it was... After digging around a bit I was able to find posts_per_page under $wp_query->query_vars[].
So, here's my fix:
Replace
$max_page = $wp_query->max_num_pages;
with
$max_page = $wp_query->query_vars['posts_per_page'];
My question is this... How does this even get shipped out for download to users if it's completely broken?
If it's NOT broken for anyone else, why am I having problems? What would cause max_num_pages to be NULL?
If there is a bug or something, this is as far as I've traced it back:
Line 2266 in wp-includes/query.php:
$this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
$this->found_posts == 0
$q['posts_per_page'] == 6 (correct)
So, I looked for found_posts:
Lines 2263 and 2264:
$found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
$this->found_posts = $wpdb->get_var( $found_posts_query );
$found_posts_query == 'SELECT FOUND_ROWS()'
So that calls $wpdb->get_var(SELECT FOUND_ROWS()), which, unless I'm wrong, isn't even a valid database call...
Comments
I think I had the issues becuase I upgraded... I should have backed up the database and just installed a fresh copy of 2.7 and imported the old posts...
Add a comment:
To add a link, please use the following format:
[link]domain.com/page.htm[/link]Do not add www or http to the URL.
Comment Preview: