PHP Notices in get_body_class() for certain query conditions
|Reported by:||dd32||Owned by:||nacin|
get_body_class() uses get_queried_object(), however, expects that the returned object will be the same as the conditional it's testing.
For example: /author/admin/?cat=1 triggers is_author() and is_category(), however, queried_object() will be a Category object.
get_body_class() checks to see if is_author() before is_category() and as a result, attempts to use a Category object as a Author object.
The solution here is to have the same setting order in all locations (ie. In the code that sets queried_object, and code which iterates through conditionals and then expects to use the queried object).
Another alternative is to call get_userdata() / get_term() instead of relying upon the queried object.
Relying upon the queried object has the obvious downside at present that it can only contain a single object, whereas, WordPress can recieve a request made up of "multiple objects".
Change History (12)
comment:9 wonderboymusic — 19 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.5
comment:10 nacin — 18 months ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed