WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom taxonomy, "position", with multiple terms for a custom post type, "employee" in the admin. I want to validate the form to require a position to be selected when you save/update a post.

How do I validate and make the position custom taxonomy a required field in the wordpress admin?

Also, I'd like to display an error message to indicate to users that a position is required to be checked.


share|improve this question

I've posted an answer to very similar question here which provides a "framework" to validate post fields (title,content...) meta fields (any metabox) and taxonomies (category, tags, custom) by ajax before submiting the post.

share|improve this answer

following this tutorial i replaced the standard taxonomy metabox with a custom metabox that has a set of radio buttons. (the tutorial uses a select, but it isn't that different). this way you can ensure that something is selected AND limit the selections to a few pre-defined options.


there is a note about how to remove the default metabox, but you can prevent the UI from ever displaying by declaring show-ui to false when you define your taxonomy.

share|improve this answer

I'd say, hook into pre_post_update and check what is given via $_POST...

share|improve this answer

Assuming you are using a hierarchical taxonomy this worked for me, change 'tx' to whatever you called your taxonomy. Note, if WP change their HTML structure in the future or naming conventions this may not work.

add_action('admin_footer', function() {
<script type="text/javascript">
    jQuery(document).ready(function ($) {
        var tx = 'post-type';

        var $scope = $('#' + tx + '-all > ul');
            if ($scope.find('input:checked').length > 0) {
                return true;
            } else {
                alert('not found');
                return false;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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