[wp-trac] [WordPress Trac] #16168: 404 error with pagination on custom taxonomy page

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 15 01:28:22 UTC 2011


#16168: 404 error with pagination on custom taxonomy page
--------------------------+----------------------
 Reporter:  kamiyeye      |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  General       |     Version:  3.0.4
 Severity:  major         |  Resolution:  invalid
 Keywords:                |
--------------------------+----------------------
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 You're doing it wrong.

 Query_posts unfortunately has the effect, that it runs AFTER the query has
 already been made, as a result, this means that the page will 404 before
 your template is even loaded as expected (The query before your
 query_posts only has 4 pages).

 You need to use a hook such as 'pre_get_posts' or you need to hook
 posts_request (i think that's it, not sure) and set the posts_per_page on
 a conditional -based on the current query-, not make a new query.

 Valid places for using query_posts: None. Seriously, Use a custom WP_Query
 instance inline in a page if you need to have another loop inside a loop,
 but don't replace the main loop using query_posts.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16168#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list