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のテキストウィジェットでoEmbedを有効化する方法

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

最近、あるユーザーからWordPressのテキストウィジェットでoEmbedを有効化する方法を尋ねられました。 oEmbedとは、動的コンテンツを埋め込むために必要なHTMLを提供するよう、ブログがoEmbed対応サイトに依頼できるプロトコルです。簡単に言うと、ブログ投稿にYouTube動画のURLを貼り付けるだけで、WordPressが自動的に埋め込むことができます。手動でoEmbedの最大幅を調整したり、動的にoEmbedコンテンツの幅と高さを変更することができます。しかし、oEmbedを使ってテキストウィジェットにコンテンツを埋め込むことはできません。この投稿では、WordPress のテキストウィジェットで oEmbed を有効化する方法を紹介します。

すべて、テーマのfunctions.phpファイルまたはサイト固有のプラグインに、次のコードを追加するだけです:

[cbk1]

これができたら、完了です。これでテキストウィジェットのoEmbedが有効化されました。外観 ” ウィジェットでテストできます。テキストウィジェットにYoutube動画のURLを追加して、マジックを見てください。

このコードが何をするのか知りたい人のために説明すると、単純にwidget_textフィルターを追加し、テキストウィジェットがoEmbed用のショートコードを実行し、コンテンツを自動埋め込みできるようにします。

コードを扱うのが好きでない人のために、Text Widget oEmbedプラグインを有効化した。それは文字通り同じことを行います。プラグインには、上記で共有した2行のコードしかありません。

この投稿が、テキストウィジェットでoEmbedを有効化するのにお役に立てば幸いです。ご質問やコメントがありましたら、以下にコメントを残してお知らせください。

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 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

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

  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. Fernando says

    Thanks for the tip but has a problem, that the media content doesn’t adapt to the sidebar width, something that we can control with the embed code and not with the plugin or the code.

返信を残す

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