WordPress カテゴリーの選択をチェックボックスからラジオボタンに変更すると同時に
「新規カテゴリーを追加」と「よく使うもの」を非表示にする
function.php内に記述 例:カスタム投稿タイプは「information」タクソノミーは「information_category」
以下はデフォルト投稿とカスタム投稿を併用する場合。
// お知らせカテゴリーの選択をラジオボタンに変更-------------------------------------------
function change_category_to_radio() {
echo "<script>
jQuery(function($) {
// カテゴリーをラジオボタンに変更
$('#categorychecklist input[type=checkbox]').each(function() {
$(this).replaceWith($(this).clone().attr('type', 'radio'));
});
$('#information_categorychecklist input[type=checkbox]').each(function() {
$(this).replaceWith($(this).clone().attr('type', 'radio'));
});
// 「新規カテゴリーを追加」を非表示
$('#category-adder').hide();
$('#information_category-adder').hide();
// 「よく使うもの」を非表示
$('#category-tabs').hide();
$('#information_category-tabs').hide();
});
</script>"; }
add_action( 'admin_head-post-new.php', 'change_category_to_radio' );
add_action( 'admin_head-post.php', 'change_category_to_radio' );