親カテゴリーも勝手にチェックが入って欲しいとき、以下のコードを functions.php に追加(PHPの閉じタグ・開きタグが入っているので注意)。js を使って親カテゴリーにチェックが入るようにしています。
/**
* 子カテゴリーを選択したら自動で親カテゴリーが選択される
* (PHP 閉じタグ・開きタグが入ってるので注意)
*/
function category_parent_check_script()
{
?>
<script>
jQuery(function($) {
$('#taxonomy-category .children input').change(function() {
function parentNodes(checked, nodes) {
parents = nodes.parent().parent().parent().prev().children('input');
if (parents.length != 0) {
parents[0].checked = checked;
parentNodes(checked, parents);
}
}
var checked = $(this).is(':checked');
$(this).parent().parent().siblings().children('label').children('input').each(function() {
checked = checked || $(this).is(':checked');
})
parentNodes(checked, $(this));
});
});
</script>
<?php
}
add_action('admin_head-post-new.php', 'category_parent_check_script');
add_action('admin_head-post.php', 'category_parent_check_script');