[wp-trac] [WordPress Trac] #9269: Proper handling of custom taxonomy in query

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 3 20:58:20 GMT 2009


#9269: Proper handling of custom taxonomy in query
--------------------------+-------------------------------------------------
 Reporter:  dfellars1     |       Owner:  ryan                      
     Type:  defect (bug)  |      Status:  new                       
 Priority:  normal        |   Milestone:  Unassigned                
Component:  Permalinks    |     Version:  2.7.1                     
 Severity:  normal        |    Keywords:  taxonomy wp_queried_object
--------------------------+-------------------------------------------------
 Currently a custom taxonomy does not have the same behavior as
 tags/categories when dealing with permalink query.  Getting a 404 with
 taxonomies when there are no posts associated with a taxonomy (I have
 hierarchical custom taxonomies, so some don't have posts)

 There are 2 issues:
 1) in classes.php handle_404() function, there is no exception check for
 is_tax() to override scenario if no posts associated with a custom tax -
 that should be a simple add of (is_tax() || is_tag().....

 2) wp_queried_object() on this line in handle_404 returns NULL when there
 are no sub-terms associated with the term in the query. So it still
 process
 This can get fixed either by removing the isempty($term) in
 wp_queried_object under this $this->is_tax block that causes it to return
 NULL in wp_queried_object. OR change the call to get_terms to add
 'hide_empty' => false as an argument.  Since in this scenario, it returns
 a single term where slug=$slug, but it gets removed since by default
 hide_empty is true and this term doesn't have any posts.

 I've looked at who else would use this section for taxonomies and the only
 place I really saw it being used was in wp_head()

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9269>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list