Opened 15 years ago
Closed 15 years ago
#8179 closed defect (bug) (worksforme)
query_posts + showposts + permalinks = 404
Reported by: | wp_guy | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 2.7 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
So, apparently when doing something like query_posts($query_string.'showposts=2'); in a category.php file for example. Everything seems to work fine, but the paging doesn't, I get 404 errors on the 3rd page.
Here is how the blog is setup:
- 'Blog pages show at most' is set to 5 in the settings
- category.php has a query_posts($query_string.'showposts=2');
- the category I'm browsing contains 7 posts.
- permalinks are set to 'month and name'
Here is what I do:
- myblog.com/category/mycategory works fine, shows 2 posts
- myblog.com/category/mycategory/page/2 works fine too, shows the next 2 posts
- myblog.com/category/mycategory/page/3 returns a 404 error.
The above works just fine if I use the default permalink structure (query string).
I've seen this error in 2.6.3 and 2.7, haven't tried on earlier versions
Change History (5)
#3
in reply to:
↑ 2
;
follow-up:
↓ 4
@
15 years ago
I can't reproduce this.
Really? are you sure? have you tried going further back? I think it depends on the number of posts.
e.g.
7 posts: 1st page ok (posts 1 and 2) WP must somehow think it's showing 1-5,
2nd page ok (posts 3 and 4) WP must think it's showing 6-7,
3rd 404 error, I suppose because posts 10 to 15 don't exist (?)
if I add an error_log($GLOBALSwp_query?->query_varsposts_per_page?) I can see it go from '2' on the pages that work to '5' when I get the 404 error. Don't know if that matters.
There is a number of forum post on the matter. This one for example http://wordpress.org/support/topic/197628
Are you sure that your
$query_string
variable consistently ends with an ampersand?
I'm sure... I just forgot to add it when I submitted the ticket.
#4
in reply to:
↑ 3
@
15 years ago
Replying to wp_guy:
I can't reproduce this.
Really? are you sure? have you tried going further back? I think it depends on the number of posts.
If I put the following in category.php, I can go back at least 10 pages (that's where I stopped).
$cat = get_query_var('cat'); $page = get_query_var('paged'); query_posts("paged=$page&cat=$cat&showposts=2");
But that's on the latest trunk.
I can't reproduce this. The following works fine:
Are you sure that your
$query_string
variable consistently ends with an ampersand?