-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for taxonomies with mandatory selection #95
Comments
Yeah I'd definitely be happy to take a look at a PR for that. There's some semi-related code in place already which allows for a fallback default term from a stored option if you use a taxonomy term in the permalink structure. See also #71. |
By reading the documentation I was under the assumption that But it seems it is just adding a required attribute (and only in the dropdown widget) that has no effect at all (at least in Gutemberg) because the taxonomy still accepts the empty value. Shouldn't that be the role of the required option? |
@nreynis I was also surprised to find this out about |
I've been hoping for this feature as well, so I investigated the Required Taxonomies plugin mentioned in the previous comment. Unfortunately the author of that plugin has decided to make custom post type support a premium feature... (but it's licensed GPLv2 and the code itself looks pretty minimal aside from the embedded promotional stuff, so it's prob not too hard to adapt...) |
I'm wondering if you'd be interested in a PR which adds support for registering a custom taxonomy where a term must always be selected (same behaviour as the
category
taxonomy). I can think of a few approaches to this but my preference would be to add two parameters to the registration function:allow_empty
: defaulttrue
, acceptsbool
default_term
: defaultnull
, acceptsstring (term name)
When
allow_empty
is set tofalse
, the first term listed will be selected by default and theNo <taxonomy name>
option will be removed from radio / dropdown taxonomies. Ifdefault_term
is set to a string, a matching term will created and selected by default (or selected if it exists). Thoughts?(Note: the
default_term
could be used for taxonomies which allow no selection as well, so maybe this could be two PRs.)The text was updated successfully, but these errors were encountered: