WordPress.org

Make WordPress Core

Opened 16 months ago

Last modified 3 months ago

#43517 reviewing enhancement

Adding support of default category term for custom taxonomies

Reported by: enrico.sorcinelli Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.1
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

This patch aims to add the support for default category term in custom taxonomies in the same way that is done for built-in taxonomies.

The new default_term argument is added to register_taxonomy() allowing to define the default term name and optionally slug and description. For example:

register_taxonomy( 'custom-tax', 'my-cpt', array(
   'default_term' => array( 'name' => 'My default category', 'slug' => 'default-category' ),
));

This way, by inserting a new my-cpt object without setting any custom-tax terms, the default term 'My default category' will be used for that taxonomy.

The default_taxonomy_{$axonomy} value is used as option_name in order to save default terms id in wp_options.

PS: Apparently, I haven't found any related ticket other than this old one.

Attachments (1)

43517.patch (6.9 KB) - added by enrico.sorcinelli 16 months ago.

Download all attachments as: .zip

Change History (11)

#1 @mukesh27
16 months ago

  • Keywords has-patch added

#2 @enrico.sorcinelli
16 months ago

  • Keywords has-unit-tests added

This ticket was mentioned in Slack in #core by enrico.sorcinelli. View the logs.


16 months ago

#4 @SergeyBiryukov
16 months ago

  • Milestone changed from Awaiting Review to 5.0

#5 @SergeyBiryukov
15 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#7 @pento
9 months ago

  • Milestone changed from 5.0 to 5.1

#9 @pento
6 months ago

  • Milestone changed from 5.1 to 5.2

#10 @SergeyBiryukov
3 months ago

  • Milestone changed from 5.2 to 5.3

Missed the 5.2 Beta 1 deadline, moving to 5.3.

Note: See TracTickets for help on using tickets.