0
1

More than 3 years have passed since last update.

WordPressで管理画面の「編集」「クイック編集」「ゴミ箱」「プレビュー」の項目を非表示にする

Posted at

ワードプレスのテーマtwentytwentyoneを基盤に、管理画面のサイドバーのメニューの順番を並び替える実装を行ったので、備忘録的にこの記事を残す。

環境情報

PHP:version 7.3.12
WordPress:version 5.5.3
WPテーマ:twentytwentyone

作業

functions.php
function custom_action_row( $actions ) {
    unset($actions['edit']); //編集
    unset($actions['inline hide-if-no-js']); //クイック編集
    unset($actions['trash']); //ゴミ箱
    $postType = get_post_type();
    if ( $postType == 'works' || $postType == 'topic' ) {
        unset($actions['view']); //プレビュー
    }
    return $actions;
}
add_filter( 'post_row_actions', 'custom_action_row', 10, 2 );

※「works」と「topic」のカスタム投稿だけ「プレビュー」を削除するようにしています。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1