Support

Account

Home Forums Front-end Issues How to remove search box for Taxonomy field? Reply To: How to remove search box for Taxonomy field?

  • Hi sabrinazeiden,

    You’re absolutely right about using the select2_args filter – that’s the correct approach since Taxonomy fields use Select2 but don’t expose the “Stylized UI” option. Here’s the JavaScript that will remove the search box:

    javascript
    acf.add_filter(‘select2_args’, function(args, $select, settings) {
    // Check if this is a taxonomy field
    if (settings.field_type === ‘taxonomy’) {
    // Remove the search functionality
    args.minimumResultsForSearch = -1;
    }
    return args;
    });
    Alternative approach – if you want to target specific taxonomy fields by their key or name:

    javascript
    acf.add_filter(‘select2_args’, function(args, $select, settings) {
    // Target by field key
    if (settings.field_key === ‘field_1234567890abc’) {
    args.minimumResultsForSearch = -1;
    }

    // OR target by field name
    if (settings.field_name === ‘your_taxonomy_field_name’) {
    args.minimumResultsForSearch = -1;
    }

    return args;
    });
    Where to add this code:

    In your theme’s JavaScript file that loads in admin

    Or in the ACF admin footer using this PHP:

    php
    add_action(‘acf/input/admin_footer’, function() {
    ?>
    <script>
    acf.add_filter(‘select2_args’, function(args, $select, settings) {
    if (settings.field_type === ‘taxonomy’) {
    args.minimumResultsForSearch = -1;
    }
    return args;
    });
    </script>
    <?php
    });
    The minimumResultsForSearch = -1 trick tells Select2 to never show the search box, regardless of how many options there are. This is much cleaner than trying to hide it with CSS.

    This should completely remove the search dropdown from your Taxonomy select fields while keeping the regular Select fields unaffected.