Make WordPress Core

Opened 3 years ago

Last modified 10 months ago

#21821 new defect (bug)

wp_title spits warnings and returns a blank when a query is both is_post_type_archive and is_category/is_tax/etc

Reported by: devesine Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.4
Component: Themes Keywords: needs-patch
Focuses: template Cc:


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.

Attachments (1)

isVarious.php (1.5 KB) - added by devesine 3 years ago.

Download all attachments as: .zip

Change History (10)

@devesine3 years ago

comment:1 @SergeyBiryukov3 years ago

Related/duplicate: #18614, #19035, #20994

comment:2 @greenshady3 years ago

  • Cc justin@… added

comment:3 @DrewAPicture3 years ago

  • Cc xoodrew@… added

comment:4 @SergeyBiryukov3 years ago

  • Version changed from trunk to 3.4

comment:5 @serons3 years ago

  • Cc serons added

comment:7 @lkraav2 years ago

  • Cc leho@… added

Yeap, hitting this in 3.5.2

comment:8 @nacin19 months ago

  • Component changed from Template to Themes
  • Focuses template added

comment:9 @obenland10 months ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.