Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Limit Category to 1 Category in Edit Screen.
- */
- function limit_cat_to_one() {
- if ( is_admin() ) {
- ?>
- <script>
- jQuery( document ).ready( function ( $ ) {
- $( "#category-all input:checkbox" ).change( function () {
- var max = 1;
- var count = $( "#category-all input:checked" ).length;
- if ( count > max ) {
- $( this ).prop( "checked", "" );
- alert( "You can choose " + max + " Categor" + (
- max == 1 ? "y" : "ies"
- ) );
- }
- } );
- } );
- </script>
- <?php
- }
- }
- add_action( 'admin_head', 'limit_cat_to_one' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement