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

Jak włączyć oEmbed w widżetach tekstowych WordPress?

Niedawno jeden z naszych użytkowników zapytał nas, jak włączyć oEmbed w widżetach tekstowych WordPress. oEmbed to protokół, który pozwala twojemu blogowi poprosić witrynę internetową obsługującą oEmbed o dostarczenie kodu HTML potrzebnego do osadzania dynamicznych treści. Mówiąc prościej, pozwala to po prostu wkleić adres URL filmu z YouTube we wpisie na blogu i pozwolić WordPressowi osadzać go automatycznie. Można ręcznie ustawić maksymalną szerokość o Embed lub dynamicznie zmieniać szerokość i wysokość treści oEmbed. Nie można jednak osadzać treści w widżecie tekstowym za pomocą oEmbed. W tym artykule pokażemy, jak włączyć oEmbed w widżetach tekstowych WordPress.

Wszystko, co musisz zrobić, to dodać następujący kod do pliku functions. php twojego motywu lub wtyczki specyficznej dla witryny:

1
2
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 );

.

Gdy już to zrobisz, gotowe. Pomyślnie włączono oEmbed dla widżetów tekstowych. Możesz przejść do Wygląd ” Widżety, aby to przetestować. Po prostu dodaj adres URL filmu z Youtube do twojego widżetu tekstowego i obserwuj magię.

Dla tych, którzy chcą wiedzieć, co robi ten kod, po prostu dodaje filtr widget_text umożliwiający widżetom tekstowym uruchamianie krótkiego kodu dla oEmbed i automatyczne osadzanie treści.

Dla tych, którzy nie lubią zajmować się kodem, można po prostu włączyć wtyczkę Text Widget oEmbed. Robi ona dosłownie to samo. Wtyczka ma tylko 2 linie kodu, które udostępniliśmy powyżej.

Mamy nadzieję, że ten artykuł pomógł ci włączyć oEmbed w widżetach tekstowych. Jeśli masz jakieś pytania lub uwagi, daj nam znać, zostawiając komentarz poniżej.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

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.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

2 komentarzeLeave a Reply

  1. Jonathan

    Is this code not enough?

    add_filter ('widget_text', array ($ wp_embed, 'autoembed'), 8);

  2. Fernando

    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.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.