How to add HTML5 ‘required’ attribute to wp_dropdown_categories() without JavaScripts?
I’m using wp_dropdown_categories() for populating <select> field with custom taxonomy terms. If the code is like below: <?php $args = array( ‘show_option_none’ => __( ‘Select one’, ‘text-domain’ ), ‘taxonomy’ => ‘my_tax’, ‘id’ => ‘tax-type’, ‘echo’ => 1, ); wp_dropdown_categories( $args ); It’s working just fine. I can make the field mandatory with jQuery: $(‘#tax-type option:first’).val(null); … Read more