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ウィジェットにカスタマイザーを簡単に追加する方法を紹介する。

Adding custom styles to WordPress widgets

WordPressウィジェットにカスタマイザーを追加する3つの方法を紹介します。あなたに最適なものを選んでください。

この投稿を始める前に、ウィジェットのスタイルを設定するためのCSSの知識が必須である。また、WordPressテーマにカスタムCSSを追加する必要があります。

CSSの代わりにコードを使わない方法をお望みなら、3の方法まで読み飛ばして構わない。

始めよう。

ブロックエディターを使ってWordPressウィジェットにカスタマイザーを追加する

WordPressのウィジェットは、ブロックエディターを使ってウィジェット対応エリアやサイドバーにウィジェットやブロックを追加できるようになりました。

ウィジェット用のブロックエディターを使う利点の一つは、各ブロックにカスタマイザー・クラスを簡単に追加できることです。

外観 ” ウィジェットページに行き、カスタムスタイルを追加したいウィジェットをクリックするだけです。

Adding custom CSS class to widgets in Block Editor

次に、ブロックパネルの下のAdvancedタブまでスクロールダウンする必要があります。ここからカスタムCSSクラスを追加できます。

更新ボタンをクリックして変更を保存することを忘れないでください。

これで、WordPressテーマに特定のCSSクラスをターゲットにしたカスタマイザーを追加できる。

外観 ” カスタマイザーページに行き、追加CSSタブに切り替えるだけです。あなたのサイトのライブプレビューが表示され、CSSルールを追加するボックスが表示されます。

Add CSS rules

:外観メニューの下にカスタマイズが表示されない場合は、WordPress管理画面のテーマカスタマイザーが表示されないのを修正する方法の投稿をご覧になるか、WPCodeプラグインを使用してカスタムCSSを追加してください。

以下は、私たちが使用した基本的なCSSです。

.latest-articles { 
background-color:#def4f1;
padding:10px;
}

カスタムCSSを追加した後、サイトをプレビューしてその動作を確認することができます。

Block widget with custom style preview

ブロック・エディター・ウィジェットを使用する際に問題となるのは、対象となる適切なブロックを見つけることである。

より簡単な方法は、ブロックをグループブロックに追加して、簡単にまとめてスタイルを設定することです。ブロックのグループ化については、WordPressブロックエディターの使い方ガイドをご覧ください。

WordPressのクラシックウィジェットにカスタマイザーを追加する

この方法は、WordPressサイトで古いクラシックウィジェットを使用している場合に適しています。

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

Widget Optionsは、WordPressのウィジェットに追加オプションを追加する強力なプラグインです。これには、ユーザー端末、権限グループ、その他の条件に基づいてウィジェットを表示したり非表示にしたりする機能が含まれます。

プラグインはまた、WordPressウィジェットにカスタマイザークラスを追加するオプションを追加します。

外観 ” ウィジェットページに行き、カスタムスタイルを追加したいウィジェットをクリックするだけです。

ウィジェット設定では、幅広いオプションが表示されます。ここから、カスタムCSSクラスを追加するには、歯車アイコンをクリックする必要があります。

Adding custom CSS class via Widget Options

設定が完了したら、保存ボタンをクリックしてウィジェット設定を保存することを忘れないでください。

入力したCSSクラスを使って、テーマにカスタムCSSルールを追加できるようになりました。例えば、テストサイトでは以下のCSSを使用しました。

.latest-articles { 
background-color:#def4f1;
padding:10px;
}

テストサイトではこのように表示された。

Classic widget preview

CSS HeroでWordPressウィジェットにカスタマイザーを適用する

上記の2つの方法の1つの問題は、CSSコードを書く必要があるということです。しかし、すべてのユーザーがCSSを知っているわけではないし、自分でコードを書きたくないだけなのだ。

そんなときは、CSS Heroを使えばいい。これはWordPressスタイリングのカスタム・プラグインで、コードを書かずにWordPressテーマにカスタムCSSを追加できる。

まず、CSS Heroプラグインをインストールして有効化する必要があります。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

プラグインを有効化すると、WordPress管理画面のツールバー上部に新しいメニュー項目が追加されます。

次に、スタイル設定したいウィジェットが表示されているページにアクセスし、上部にあるCSS Heroボタンをクリックする必要があります。

CSS Hero button

これでCSSヒーローエディターインターフェースでページが開きます。

ライブエディターで、サイト上の項目をポイント&クリックするだけで、そのスタイルを変更できる。

CSS Hero editor

スタイル設定したいウィジェットにマウスオーバーし、クリックして選択するだけです。

その後、左側のメニューを使って、好きなようにウィジェットをスタイルすることができます。

Select and edit the widget

これには、グラデーション、タイポグラフィ、パディング、マージン、枠線などの高度なスタイル設定オプションが含まれます。

Styling options in CSS Hero

設定が完了したら、Saveボタンを押して設定を保存することをお忘れなく。

サイトをプレビューして、変更を確認することができます。

Widget preview CSS Hero

この投稿が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

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

  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!

  2. Ankush says

    The Plugin was really Great but I had a problem…

    It doesn’t work when i add custom css….

    May be plugin css is overriding my code but.. that really sad…

    Hey Wpbeginner.com Team.. Please leave me a reply,]

    I You can tell me how to fix it…

  3. Rachael says

    I love this plugin but every time I activate it, I have trouble with the gallery widget. It works fine with the plugin deactivated, but if I turn on the plugin, the gallery widget won’t save any images. All of the other widgets work fine. Does anyone else have this issue?

  4. Regina says

    Does how to instructional above also also include the ability to customize the font of the widget titles?
    Thanks!

  5. terry says

    Finally, after failing at trying to decode the jargon I get on inspect, this article told me exactly what I needed.

    Thanks

  6. irfan says

    There is extra white space while creating extra widget area for header. Kindly tell us , how to remove this

  7. Thomas says

    Hi, I tried to do it manually, inspected the element and its class but it did not work.

    I am trying to change the style of a WPform.

    Could you help me?

  8. daniel says

    i have added a widget area to my header using the functions.php and header.php files. i can see the widget ive added on my site but i want to put it next to the menu, any idea how to do this please? i want it to sit to the right hand side of the menu.

  9. Deniz Kumru says

    It’s my first wordpress theme.I was nervous till found your article.It’s done thank you :)

  10. ivan says

    Why does my layout under widget styles only shows the padding option, without the bottom margin, gutter & row layout option.

  11. Rimi says

    hallo
    I can not make any changes because it is inactive
    Being processed plugin / css / plugin-front.css (inactive),How can I activate pleas

  12. Grace says

    Hello, my theme doesn’t have a right sidebar, it came with just a footer widget area, can I use the custom css to add a right sidebar? Please help me, thanks

    • WPBeginner Support says

      No, you will first need to define a widget ready area. Your theme may already have an option to use a sidebar layout. If it doesn’t, then we would recommend you to ask the theme author for support. On the other hand, if you feel confident in your coding skills, then go a head.

      管理者

  13. Mr.T says

    I want to change them manually. Am I right that by using widget-number class you actually can’t move them up or down in the widgets area, because their id will change, or it works differently?

  14. Correen K says

    I was looking for something like this to add some style to my sidebar and stumbled upon the Flexible Posts Widget plugin. I think it’s always nice to have options ;)

返信を残す

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