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

Cómo activar oEmbed en los widgets de texto de WordPress

Recientemente, uno de nuestros usuarios nos preguntó cómo activar oEmbed en los widgets de texto de WordPress. oEmbed es un protocolo que permite a tu blog pedir a un sitio web activado para oEmbed que proporcione el HTML necesario para incrustar contenido dinámico. En palabras sencillas, te permite pegar la URL de un vídeo de YouTube en una entrada de blog y dejar que WordPress lo incruste automáticamente. Puedes ajustar el ancho máximo de oEmbed manualmente, o cambiar dinámicamente el ancho y alto del contenido de oEmbed. Sin embargo, no puedes incrustar contenido en un widget de texto usando oEmbed. En este artículo, le mostraremos cómo activar oEmbed en los widgets de texto de WordPress.

Todo lo que tienes que hacer es añadir el siguiente código en el archivo functions. php de tu tema o en un plugin específico del sitio:

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

Una vez hecho esto, ya está. Has activado / activado correctamente oEmbed para widgets de texto. Puedes ir a Apariencia ” Widgets para probarlo. Simplemente añade la URL de un video de Youtube en tu widget de texto, y observa la magia.

Para aquellos que quieran saber lo que hace este código, simplemente añade un filtro widget_text que permite a los widgets de texto ejecutar shortcode para oEmbed y auto incrustar contenido.

Para aquellos que no les gusta lidiar con el código, entonces usted puede simplemente activar Text Widget oEmbed plugin. Literalmente hace lo mismo. El plugin solo tiene 2 líneas de código que compartimos arriba.

Esperamos que este artículo te haya ayudado a activar oEmbed en los widgets de texto. Si tienes alguna pregunta o comentario, por favor háznoslo saber dejando un comentario a continuación.

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 comentariosLeave 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.