Make WordPress Core

Opened 2 years ago

Last modified 7 months ago

#43517 reviewing enhancement

Adding support of default category term for custom taxonomies

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


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 (2)

43517.patch (6.9 KB) - added by enrico.sorcinelli 2 years ago.
43517.2.diff (7.2 KB) - added by davidbaumwald 7 months ago.
Refreshed patch

Download all attachments as: .zip

Change History (16)

#1 @mukesh27
2 years ago

  • Keywords has-patch added

#2 @enrico.sorcinelli
2 years ago

  • Keywords has-unit-tests added

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

2 years ago

#4 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 5.0

#5 @SergeyBiryukov
2 years ago

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

#7 @pento
18 months ago

  • Milestone changed from 5.0 to 5.1

#9 @pento
15 months ago

  • Milestone changed from 5.1 to 5.2

#10 @SergeyBiryukov
13 months ago

  • Milestone changed from 5.2 to 5.3

Missed the 5.2 Beta 1 deadline, moving to 5.3.

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.

8 months ago

#12 @desrosj
8 months ago

  • Keywords needs-refresh added

43517.patch needs a refresh against current trunk. @SergeyBiryukov are you still up for reviewing this one?

7 months ago

Refreshed patch

#13 @davidbaumwald
7 months ago

  • Keywords needs-refresh removed

@SergeyBiryukov I refreshed the patch an cleaned up a couple of things. Is this something that can be reviewed in time for 5.3 Beta 1 tomorrow or should this have more time for testing?

#14 @davidbaumwald
7 months ago

  • Milestone changed from 5.3 to Future Release

The deadline for version 5.3 Beta 1 enhancements is now passed, so this is being moved to Future Release.

Note: See TracTickets for help on using tickets.