[wp-trac] [WordPress Trac] #16149: Allow querying for the standard post format

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 7 23:28:21 UTC 2011


#16149: Allow querying for the standard post format
--------------------------+-----------------------
 Reporter:  nacin         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  3.1
Component:  Query         |    Version:  3.1
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------
 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.

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


More information about the wp-trac mailing list