[wp-trac] [WordPress Trac] #20438: Custom Post Types with Post Format support aren't registered against post_format taxonomy

WordPress Trac noreply at wordpress.org
Fri Feb 26 16:00:45 UTC 2021


#20438: Custom Post Types with Post Format support aren't registered against
post_format taxonomy
-------------------------------+-----------------------
 Reporter:  batmoo             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  reopened
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  needs-codex        |     Focuses:
-------------------------------+-----------------------
Changes (by cowshase):

 * keywords:   => needs-codex
 * status:  closed => reopened
 * resolution:  invalid =>


Comment:

 Replying to [comment:3 nacin]:

 > If you are going to add UI support for post formats, you should just add
 the object type to the taxonomy as well.
 >
 > So:
 > {{{
 > add_post_type_support( 'page', 'post-formats' );
 > register_taxonomy_for_object_type( 'post_format', 'page' );
 > }}}
 >
 > We discussed this in 3.1. Given that using post formats for something
 other than posts is generally not going to be a good idea (or at least a
 very uncommon one), I certainly think two lines is just fine, rather than
 one plus doing something to unnecessarily automate this in core.

 I think the documentation on [https://wordpress.org/support/article/post-
 formats/#adding-post-type-support] should be amended accordingly.

 If you register a post type with post-format support, but do not also
 manually register the post_format taxonomy to it, you will get a "Page not
 Found" if you try to preview custom posts that have already been
 published. It took me days to investigate this, until I found the solution
 in this ticket.

 I also think that using custom post types with post formats is not as
 uncommon anymore as it may have been 9 years ago. I use it for example to
 have two sepate sections on my site with different user roles and
 capabilities but similar content features. So, I think the best solution
 would be to reverse the initial decision, and to automatically call
 register_taxonomy_for_object_type() if the custom post type is registered
 with post-format support or the support is added later via
 add_post_type_support().

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/20438#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list