A way to set default terms for taxonomies. Similar how to the "default category" functionality works, but for any taxonomy.
composer require britco/wp-default-terms
function custom_tax_init() {
register_taxonomy('custom-tax', array('post'), array(
'defaults' => array(
'Foo'
)
));
}
You can also specify different defaults for different post types
function custom_tax_init() {
register_taxonomy('custom-tax', array('post', 'custom_post_type'), array(
'defaults' => array(
'post' => array(
'Foo'
),
'custom_post_type' => array(
'Bar'
)
)
));
}
Also, you can set defaults for already registered taxonomies
$taxonomy = get_taxonomy('post_tag');
$taxonomy->defaults->set(array('paper'));
Available under the MIT License.