WordPressの管理画面で記事一覧ページにあるクイック編集を使えないようにしたいということがあったので、クイック編集を削除する方法をメモ。
サンプルコード
投稿のクイック編集を削除してみます。
functions.php
1 2 3 4 5 6 | // 投稿のクイック編集を削除 function hide_quickedit( $actions ) { unset( $actions [ 'inline hide-if-no-js' ] ); return $actions ; } add_filter( 'post_row_actions' , 'hide_quickedit' ); |
hide_quickedit()の引数に入る$actionsの中は以下のようになっています。
1 2 3 4 5 6 7 8 9 10 | array (4) { [ "edit" ]=> string(156) "<a href=" http: //~略~" aria-label="“長い投稿” を編集する">編集</a>" [ "inline hide-if-no-js" ]=> string(124) "<a href=" # " class=" editinline " aria-label=" 「xxx」をインラインでクイック編集 ">クイック編集</a>" [ "trash" ]=> string(211) "<a href=" http: //~略~" class="submitdelete" aria-label="「xxx」をゴミ箱に移動">ゴミ箱へ移動</a>" [ "view" ]=> string(189) "<a href=" http: //~略~" rel="bookmark" aria-label="“xxx” を表示">表示</a>" } |
inline hide-if-no-js の中身がクイック編集のリンクになっているので、unset()を使って削除しています。
固定ページでクイック編集を削除したい場合、以下のようになります。
functions.php
1 2 3 4 5 6 | // 固定ページのクイック編集を削除 function hide_quickedit( $actions ) { unset( $actions [ 'inline hide-if-no-js' ] ); return $actions ; } add_filter( 'page_row_actions' , 'hide_quickedit' ); |
post_row_actions を page_row_actionsに変更しています。
【参考サイト】
コメントが承認されるまで時間がかかります。