やわらかしかっけい

なんでもすぐに忘れてしまう自分のために

2020版 WordPressダッシュボードカスタマイズ

ダッシュボードトップの項目を減らす
<?php
function remove_dashboard_widget() {
  remove_action( 'welcome_panel','wp_welcome_panel' ); // ようこそ
  remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' ); // アクティビティ
  remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); // クイックドラフト
  remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); // WordPress イベントとニュース
} 
add_action('wp_dashboard_setup', 'remove_dashboard_widget' );
?>
サイドバーから「コメント」を削除
<?php
function remove_menus(){
    remove_menu_page( 'edit-comments.php' ); 
}
add_action( 'admin_menu', 'remove_menus' );
?>
投稿編集画面

Gutenbergにも対応

<?php
function remove_post_support() {
  remove_post_type_support('post','trackbacks');      // トラックバック
  remove_post_type_support('post','custom-fields');   // カスタムフィールド
  remove_post_type_support('post','tag');        // コメント
  remove_post_type_support('post','comments');        // コメント
  remove_post_type_support('post','revisions');       // リビジョン
  remove_post_type_support('post','page-attributes'); // 表示順
  remove_post_type_support('post','post-formats');    // 投稿フォーマット
  unregister_taxonomy_for_object_type( 'post_tag', 'post' ); // タグ
}
add_action('init','remove_post_support');
?>

参考
twotone.me