[wp-trac] [WordPress Trac] #43517: Adding support of default category term for custom taxonomies
WordPress Trac
noreply at wordpress.org
Sat Mar 10 17:07:43 UTC 2018
#43517: Adding support of default category term for custom taxonomies
-------------------------------+-----------------------------
Reporter: enrico.sorcinelli | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
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:
{{{
#!php
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
[ticket:24948 this old one].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43517>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list