Hello,
I'm trying to trigger an action if, when a user tries to publish a post, no category is selected:
- It could either be just an alert message (and the post is still published);
- Or actually alter message + preventing the post from being published.
Searching on this forum, I've found the code:
jQuery('#submitdiv').on('click','#publish',function(e){
var $checked = jQuery('#category-all li input:checked');
if ( $checked.length <= 0 ) { //Checks if cat is selected
alert("Please Select atleast one category");
return false;
}else{ //Else continue
return true;
}
});
But I have no idea where to put it.
Thanks!