Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressで不要なウィジェットを無効化する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressで使用されていないウィジェットを無効化する方法について、多くのユーザーから問い合わせがありました。

初期設定のウィジェットエリアは、実際に使用するかどうかにかかわらず、利用可能なウィジェットを個別に表示します。このため、必要なウィジェットを見つけるのが難しく、サイトのカスタマイズに時間がかかることがあります。

未使用のウィジェットを無効化することで、サイトを真に強化し、訪問者に価値を提供するウィジェットの追加と配置に集中することができます。

この投稿では、WordPressで不要なウィジェットを無効化し、ウィジェットが散らからないようにする方法を紹介します。

Remove unwanted widgets in WordPress

なぜWordPressの不要なウィジェットを無効化するのか?

ウィジェットは、WordPressサイトのサイドバーやウィジェット準備エリアに追加できる要素のブロックです。WordPressには初期設定のウィジェットがいくつか用意されており、他のWordPressプラグインでも独自のウィジェットを追加することができます。

これらのウィジェットはすべて外観 ” ウィジェット画面で見ることができる。しかし、これらのウィジェットの中にはあまり役に立たないものもあり、おそらくあなたのサイトで使うことはないでしょう。

独自のウィジェットを追加するプラグインを使用している場合、ウィジェット画面はすぐに大混乱になり、実際に使用したいウィジェットを探すのが難しくなります。

WordPressの不要なウィジェットを無効化して、ウィジェット画面を簡単にきれいにする方法を見てみよう。

WordPressで不要なウィジェットを無効化する

最初に行う必要があるのは、WP Widget Disableプラグインをインストールして有効化することです。詳細については、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

有効化した後、外観 ” ウィジェット無効化のページでプラグイン設定を行う必要があります。

Disable widgets settings

設定ページは2つのタブに区切られている。まず、無効化したいサイドバー・ウィジェットを選択する必要があります。使用したくないウィジェットの横にあるボックスにチェックを入れ、「変更を保存」ボタンをクリックするだけです。

外観 ” ウィジェットのページで違いを確認できます。選択したウィジェットはすべてウィジェット画面に表示されなくなります。

Cleaned up widgets screen in WordPress

WordPressダッシュボード・ウィジェットを削除する方法

WordPressはダッシュボードページにもいくつかのウィジェットを表示します。プラグインやテーマによっては、WordPressダッシュボードに独自のウィジェットを追加することもできます。

通常、‘表示オプション‘ボタンをクリックし、表示したくないウィジェットのチェックを外すことで、ダッシュボード画面をクリーンアップすることができます。これは最も迅速で簡単な方法です。ユーザーが一人だけのサイトに最適です。

Cleaning up dashbaord screen in WordPress

しかし、この方法を使えば、あなたやあなたのサイトを利用する誰もが、画面オプションボタンをクリックするだけで、それらのウィジェットを再び表示できるようになります。

WP Widget Disableプラグインを使用すると、表示オプションメニューからでもダッシュボードウィジェットを非表示にすることができます。

外観 ” ウィジェットの無効化ページに移動し、ダッシュボードウィジェットタブをクリックします。

ダッシュボード画面から非表示にしたいウィジェットを選択し、「変更を保存」ボタンをクリックして設定を保存します。

ダッシュボードのページで、その動きを見ることができる。

Disabled dashboard widgets in WordPress

削除を選択したウィジェットは、ダッシュボードや画面オプションメニュー内には表示されなくなります。また、ダッシュボードに表示するWordPressダッシュボードウィジェットをカスタム作成することもできます。

WordPressダッシュボード・ウィジェットを完全に削除して、他のユーザーが簡単にオンに戻せないようにしたい場合は、テーマのfunctions.phpファイル、サイト固有のプラグイン、またはコード・スニペット・プラグインに以下のコードを貼り付ける必要があります:

function remove_dashboard_widgets() {
    global $wp_meta_boxes;
  
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
  
}
  
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );

上記の各ウィジェットは、かなり自明である。残したいウィジェットをリストから削除してください。管理者以外のすべてのユーザーからこれらのウィジェットを削除したい場合は、最後の行を次のように変更してください:

if (!current_user_can('manage_options')) {
    add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
}

WPCodeプラグインを使用してこのコードを追加することをお勧めします。テーマファイルを編集せずにWordPressにカスタムコードを追加する最も安全で簡単な方法です。

開始するには、あなたのサイトに無料のWPCodeプラグインをインストールし、有効化する必要があります。WordPressプラグインのインストール方法については、こちらをご覧ください。

プラグインを有効化したら、WordPressダッシュボードからCode Snippets ” Add Snippetにアクセスしてください。

そこから、「カスタムコードを追加(新規スニペット)」オプションにマウスオーバーし、「スニペットを使用」ボタンをクリックします。

Add a new custom code snippet in WPCode

次に、「カスタム・スニペットの作成」ページに移動します。最初に、スニペットのタイトルを追加してください。スニペットのタイトルは、何のためのコードかを覚えておくのに役立つものであれば何でもかまいません。

次に、上記のコードを「コードプレビュー」ボックスに貼り付け、ドロップダウンメニューからコードタイプとして「PHPスニペット」を選択します。

Paste your code into the WPCode plugin

その後、スイッチを’Inactive’から’Active’に切り替え、ページ上部の’Save Snippet’ボタンをクリックする。

Activate and save your custom code snippet

これでWordPressダッシュボードのウィジェットがすべて無効化されます。

WordPressで不要なウィジェットを無効化する方法について、この投稿がお役に立てば幸いです。また、WordPress サイドバーで最大の効果を得るためのトリックや、コードなしでカスタマイザーテンプレートを作成できるWordPress ページビルダー プラグインもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

10件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

    • WPBeginner Support says

      remove_meta_box can be good if you know when the meta box was added and add the code in the correct location but the unset method does not require that level of knowledge and is more guaranteed to work for a beginner :)

      管理者

  2. Maria says

    Hi.
    When I disable all the other widgets, I’m losing my search-field as well even though i do not choose this on the list. So I want to keep my search field, but not the other widgets. How can i fix this?

  3. Joshua Hoe says

    So if hiding the widgets mean Unregistered widgets will not be loaded, does it also mean that the website speed will be faster as well?

    • WPBeginner Support says

      Depending on the widgets you are disabling there could be a small speed increase but in general nothing overly noticeable in terms of speed

      管理者

  4. Luis says

    Hi,
    But how can we remove the widget area as seen in last picture? The widgets are gone, but the boxes (empty) are there to see. Can we also remove this empty boxes?

    Thanks

    • WPBeginner Support says

      You would need a different plugin for that, the plugin does not currently remove those

      管理者

  5. Jeff Yablon says

    Umm … You know this disables nothing? It HIDES them, leaves their stub coded overhead, and adds an extra plug-in.

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。