[wp-trac] [WordPress Trac] #31355: Custom hierarchical post type 404s when `get_queried_object` is called too early
WordPress Trac
noreply at wordpress.org
Wed Feb 25 04:06:49 UTC 2015
#31355: Custom hierarchical post type 404s when `get_queried_object` is called too
early
--------------------------+------------------------------
Reporter: gradyetc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.0
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by gradyetc):
Thanks for the review, Boone!
I agree with your assertion that the exceptional behavior for pages is the
bug, not the other way around as my proposal implies. I wouldn't expect a
"queried object" to be available before a query is run. (Though it is for
non-singular requests).
I think the thing that threw me off in this case was the hidden dependency
on `$queried_object_id` being unset and the unexpected side effect calling
`is_singular()` had on the query. In fact the code I reference didn't
actually need the `is_singular()` check; it just happened to be present in
a function that was being used to detect whether or not a query was for a
specific post type. (The `parse_query` hook was being used to modify sort
order for archive queries of that post type).
In practice I suspect this isn't something that people run into all that
often, and updating the documentation (and perhaps a `_doing_it_wrong()`?)
would be sufficient IMHO.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31355#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list