Allow querying for the standard post format
|Reported by:||nacin||Owned by:|
So, you currently can't query the standard post format through /type/standard/. It's not actually a term that gets stored in the database, which made this a fun puzzle to solve over the last few hours. (Props Mark as well.)
The attached patch:
- Establishes a shell 'standard' term, to prevent us from faking too much more. This is enforced in set_post_format() to ensure it never goes far.
- Reroutes the 'standard' post format request to a tax_query that does a NOT IN for every other format. It plays as nice as possible by appending to an existing tax_query and simply forcing AND.
- Corrects the query flags and the queried object, ensuring proper template selection and such.
- Performs other black magic.
This is required for 1:1 support for people who used categories. The only side effect here is, well, that it doesn't work. It's very well contained.
This additionally fixes a bug:
For taxonomies, post_type is set to 'any'. We only want post_type = 'post' for formats -- or more accurately, any post type that has chosen to support formats. Anyone doing this will need to both add_post_type_support and register_taxonomy_for_object_type, and the latter is easily fetchable with $tax->object_type. Thus, post_type is set to that.
Change History (24)
comment:1 markjaquith — 3 years ago
- Milestone changed from 3.1 to Future Release
- Type changed from defect (bug) to enhancement
comment:14 nacin — 22 months ago
- Milestone Future Release deleted
- Resolution set to maybelater
- Status changed from new to closed