I’d like to set a custom taxonomy as required, i.e. authors must select at least one term from the taxonomy in order to save or update a post of a specified set of custom post type. If they haven't done that, a custom error message displays.
I’m registering taxonomies using Extended CPTs, for example:
<?php
// Topic taxonomy
// Docs: https://github.com/johnbillion/extended-cpts/wiki/Registering-taxonomies
add_action('init', function () {
register_extended_taxonomy('topic', [
'article',
'event',
'resource',
], [
'exclusive' => false,
'hierarchical' => false,
'meta_box' => 'simple', // supports multiple (non-exclusive)
'public' => true, // applies to “publicly_queryable”, “show_ui”, and “show_in_nav_menus”
'query_var' => true,
'required' => true,
'show_admin_column' => true,
'show_in_quick_edit' => true,
'show_in_rest' => true,
], [
'singular' => 'Topic *',
'plural' => 'Topics',
'slug' => 'topic',
]);
});
How can this be accomplished (ideally, without using jQuery)?