Limit taxonomy terms added to a custom post type

I've created a Custom Post Type and a Custom Taxonomy.

In WP Admin, how can I limit amount of taxonomy terms that are added to the custom post type? I want to add no more than one tag into the post. After adding one tag, adding more should be disabled or a message should appear.

Any help appreciated much.

Topic limit custom-taxonomy custom-post-types Wordpress

Category Web


You can do it with jQuery with easyly. Count your tags and limit it!

  1. C = Re item's number
  2. L = Your limit number
  3. if ( C==L ) add class "disable" to div
$(document).ready(function(){
    var L = 10;
    var $items = $('#post_tag .tagchecklist span');
    if($items.length == L){
        $("#post_tag").addClass("disable"); // or alert("ok")
    }
});

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.