ワードプレスのテーマ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」のカスタム投稿だけ「プレビュー」を削除するようにしています。