Issue with post/comment queries
-
I recently switched hosting companies. I dumped my mysql db from the original host and imported it on the new host, as I’ve done several times before. While I was at it, I decided to go ahead and upgrade wordpress to 2.5 as well. Everything seemed to be working fine at first, until I needed to edit an entry. The “Manage” tab on wp-admin doesn’t list any posts. It gives an accurate count (Published (1,107) | Private (116)), but the actual list just says “No posts found.”
Obviously that’s not right.
Pages list correctly. Comments list correctly also. However, none of my RSS or ATOM feeds list anything, for posts or comments.
My template is showing the last 10 entries without any problem, but that might be because I invoke
<?php query_posts("showposts=10"); ?>. If I remove that, I get ALL of my posts.I enabled tracing on mysql and noticed that the query generated at line 1427 of query.php has a weird limit clause:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 2592000, 10Clearly, that’s causing a problem.
I traced it back to this bit of code in query.php:
// Paging if ( empty($q['nopaging']) && !$this->is_singular ) { $page = absint($q['paged']); if (empty($page)) { $page = 1; } if ( empty($q['offset']) ) { $pgstrt = ''; $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', '; $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; } else { // we're ignoring $page and using 'offset' $q['offset'] = absint($q['offset']); $pgstrt = $q['offset'] . ', '; $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; } }The else condition (when $q[‘offset’] is empty) is the one being run, and it appears that $q[‘offset’] is being set explicitly to 2592000. I can’t for the life of me figure out why. I tried adding ?offset=1 to the url manually, but offset remained at 2592000.
I can’t figure out where it’s coming from.
Is there a setting somewhere that might have gotten screwed up in the transfer? I didn’t find any options in wp_options that seemed relevant, and I’ve tried changing the limit on how many posts to show in wp-admin several times with no effect.
I hope someone can help, because I’m lost.
The topic ‘Issue with post/comment queries’ is closed to new replies.