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.


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
    var L = 10;
    var $items = $('#post_tag .tagchecklist span');
    if($items.length == L){
        $("#post_tag").addClass("disable"); // or alert("ok")
  • This is not working. Added to the admin_enqueue_scripts action, code is loading properly in WP Admin, but I still can add more than one tag. – SLH Nov 7 '14 at 15:31
  • 1
    Also changed $ to jQuery to avoid conflict. – SLH Nov 7 '14 at 15:39
  • This will also not work because you can add more tags separated by commas. – SLH Nov 7 '14 at 23:09
  • You can add same limit for commas. – Fatih SARI Nov 8 '14 at 9:50

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.