0

Hi i want to change my category checkboxes into radio buttons on post page, so i can select one category at a time. I tried plugin to change it but it cause my site so heavy.

0
0

I find this

function admin_js() { ?>
    <script type="text/javascript">

    jQuery(document).ready( function () { 
        jQuery('form#post').find('.categorychecklist input').each(function() {
            var new_input = jQuery('<input type="radio" />'),
            attrLen = this.attributes.length;

            for (i = 0; i < attrLen; i++) {
                if (this.attributes[i].name != 'type') {
                    new_input.attr(this.attributes[i].name.toLowerCase(), this.attributes[i].value);
                }
            }

            jQuery(this).replaceWith(new_input);
        });
    });

</script>
<?php }
add_action('admin_head', 'admin_js');

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