[wp-trac] [WordPress Trac] #21821: wp_title spits warnings and returns a blank when a query is both is_post_type_archive and is_category/is_tax/etc

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 5 23:31:39 UTC 2012


#21821: wp_title spits warnings and returns a blank when a query is both
is_post_type_archive and is_category/is_tax/etc
--------------------------+-----------------------------
 Reporter:  devesine      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Template      |    Version:  trunk
 Severity:  minor         |   Keywords:
--------------------------+-----------------------------
 When a query is made against both a post type and a category / taxonomy /
 et cetera, the query is both is_category and is_post_type_archive.  The
 queried_object is set to the first object type it comes to; category /
 taxonomy come before post_type, so the queried_object is a term here.

 wp_title walks through each is_ option in turn and resets the title with
 every one it finds being true.  When there is both a category and a post
 type archive,  single_term_title gets called first, successfully setting
 the title, but then post_type_archive_title is called, which assumes the
 queried_object is in fact a post type object; it spits out a couple of
 warnings and returns a blank title.

 Probably, since its subordinate title functions depend on the
 queried_object being as expected, wp_title should use else if rather than
 just if (in the same way that get_queried_object does), but I'm not sure
 if that would have implications elsewhere.

 (Tested against trunk r21768 as well as 3.4.1)

 Attached is a unit test that demonstrates the problem.

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


More information about the wp-trac mailing list