I have created a fairly unexciting custom type (Event) and an equally vanilla custom taxonomy (Venue). Whenever a user creates an Event, I want them to be required to either create a new Venue or select an existing Venue. How can I make this a required field when publishing?

It seems like the sort of thing that should be rather trivial but I've been going up and down http://codex.wordpress.org/Function_Reference/register_taxonomy and haven't found anything obvious. Am I going about this in the wrong way?

Any assistance would be appreciated.


You can hook an 'init' action callback in which you get the post-type and if it's 'event' check $_POST for if your taxonomy value is empty. If it's empty, you can then reset $_POST['action'] to 'edit', so that post.php simply reloads the editor. And you can inject $_GET['message'] = 11 and add your (11th) response message via hooking a callback to the 'post_updated_messages' filter. That's not ideal, but it's somewhat of a solution.

  • I've been looking around for the last week and this really appears to be the only solution. Maybe a useful direction for a new plugin. Feb 28 '11 at 14:04
  • @Robert Drake: I think this should be somehow addressed in core. It's kinda similar to another wish i have...which is ability to specify taxonomies as unique, by which i mean you can only select one value per post. There's a certain level of input logic that one can't define easily in WP, so far.
    – wyrfel
    Feb 28 '11 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.