Opened 14 years ago
Closed 14 years ago
#14324 closed defect (bug) (invalid)
404 when querying custom post types on author.php
Reported by: | truthmedia | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | post_type, author.php, 404, custom post types |
Focuses: | Cc: |
Description
Not sure if it's the only place, but on the author.php template, when you change the post_type of the loop, WordPress seems to only want to return the number of pages it WOULD have had if post_type=post was used.
Example: On our author.php template, we've changed the loop to use the following custom query:
author=123&post_type=any&post_status=publish&orderby=title&order=ASC&paged=6
In this case, it's looking for all published pages and posts (any) by the author with the ID of 123, and we're looking at page six of the results. On our site, this page shows up fine, but when we go to page 7 using the standard wordpress next/prev links we get a 404 error, in spite of the fact that there are MANY more pages and posts to be displayed.
If I configure the code to only show posts, it shows 6 pages of results which is exactly how many it SHOULD show.
Therefore, it seems that there is something in the code that detects whether or not the page is a 404, which is predisposed to only showing posts as opposed to "any".
On further analysis, the problem is a logical one, rather than a code based one. WordPress initially determines what sort of page to display (ie author or 404) based on the query obtained by the URL. Because this initial query has no post_type specified, it defaults to "post". As such, the 404 is sent long before the code would even have a chance to reach our custom query. I can probably devise a workaround, however this is still a business logic problem when custom queries are able to return more posts than the original page might have.