[wp-trac] [WordPress Trac] #14330: Multiple Post Type in Page Query Problem

WordPress Trac wp-trac at lists.automattic.com
Fri Jul 16 18:56:43 UTC 2010


#14330: Multiple Post Type in Page Query Problem
--------------------------------------------------+-------------------------
 Reporter:  loushou                               |        Owner:  loushou        
     Type:  defect (bug)                          |       Status:  closed         
 Priority:  normal                                |    Milestone:  Awaiting Review
Component:  Query                                 |      Version:  3.0            
 Severity:  major                                 |   Resolution:  fixed          
 Keywords:  post_type, WP, WP_Query, classes.php  |  
--------------------------------------------------+-------------------------
Changes (by loushou):

  * status:  accepted => closed
  * resolution:  => fixed


Comment:

 So I made a patch. Then I was looking at it an I found I could simplify
 it. So the attached file 'better-url-array-fix.patch' is the condensed
 one. I tested them against my install, and it performed exactly how I
 described it should in the bug, without breaking any of my site. However I
 would like to add that my site is pretty small with only BuddyPress as a
 plugin. This does need to be tested on bigger sites.


 == PATCH BREAKDOWN ==
 Prior to casting the query variable to a string, we need to check if it is
 an array (since WP_Query accepts arrays as parameter values). If it is,
 instead of casting the entire variable to a string, we need to cycle
 through the array, and cast each value of the array to a string. Every
 other type gets processed exactly as it did before.

 Then for the 'post_type' query var specifically (since it has it's own
 independent logic a little lower in the code), we need to modify the logic
 specifically targeting it. Again we check if the value of
 ''$this->query_vars['post_type']'' is an array. If it is, we need to
 compare each element in the list to the publicly queryable post_types.
 Once again if the value is not an array, then it is processed exactly as
 before.

 Loushou

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


More information about the wp-trac mailing list