Make WordPress Core

Opened 3 years ago

Closed 19 months ago

Last modified 3 months ago

#20438 closed defect (bug) (wontfix)

Custom Post Types with Post Format support aren't registered against post_format taxonomy

Reported by: batmoo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:


When a custom post type adds support for post-formats, this doesn't actually register the post_format taxonomy for the post_type.

Here's a quick test:

add_action( 'init', function() {
        register_post_type( 'not-post', array( 'supports' => 'post-formats' ) );
        global $wp_taxonomies;
        var_dump( 'post supports post_format:', in_array( 'post', $wp_taxonomies[ 'post_format' ]->object_type ) );
        var_dump( 'not-post supports post_format:', in_array( 'not-post', $wp_taxonomies[ 'post_format' ]->object_type ) );
} );

The post_format taxonomy doesn't get returned when get_object_taxonomies is called for the custom post type and one side-effect of this is that the post_format_relationships cache does not get flushed by clean_object_term_cache leading to stale values when a post format is changed.

(The post post_type is immune to this because core registers the post_format taxonomy with it.)

When a post_type adds support for post-formats, an explicit association should be made between the post_type and the post_format taxonomy.

Change History (10)

comment:1 @danielbachhuber3 years ago

  • Cc wordpress@… added

comment:2 @saracannon3 years ago

  • Cc sararcannon@… added

comment:3 @nacin3 years ago

If you are going to add UI support for post formats, you should just add the object type to the taxonomy as well.


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.

comment:4 @nacin3 years ago

  • Keywords close added

comment:6 @iseulde2 years ago

  • Component changed from General to Post Types

comment:7 @danielbachhuber19 months ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

comment:8 @chriscct73 months ago

#32385 was marked as a duplicate.

comment:9 @chriscct73 months ago

#31394 was marked as a duplicate.

comment:10 @chriscct73 months ago

#32385 was marked as a duplicate.

Note: See TracTickets for help on using tickets.