Wordpress 5.2 YouTube video auto-embed in posts is not working

我只是一个虾纸丫 提交于 2021-01-27 17:51:52

问题


In my personal Wordpress blog (5.2), the auto-embed for videos does not work. The editor shows a spinner (very briefly), but then it shows the link to the video in the backend and the URL in plain text in the frontend instead.

I've tried changing the post in different Browsers (all failed), I tried different videos - some from vimeo (none works). When I use the iframe embed-code provided by YouTube in the HTML-editor for the post the exact same video works fine in the same post.

I've disabled all plugins and switched to the original theme, but that did not help, the auto-embed still does not work.

It seems to know its supposed to create an embed element (judged by the code it generates for the frontend), but fails to do so apparently:

<div>
<!-- wp:core-embed/youtube {"url":"https://www.youtube.com/watch?v=ioZX_pJz-Cc","type":"video","providerNameSlug":"youtube","className":""} -->
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube">
<div class="wp-block-embed__wrapper">https://www.youtube.com/watch?v=ioZX_pJz-Cc</div>
</figure>
<!-- /wp:core-embed/youtube -->
</div>

I have no idea what to try next, and it's driving me nuts, so help would be highly appreciated.

Thanks in advance and all the best, Lucas


回答1:


There might be multiple causes. Let me state some of them:

  • you can try Youtube short URL https://youtu.be/ioZX_pJz-Cc instead. I had the same issue, using the short URL helped.
  • if echo get_the_content() is used instead of the_content();, embed code might not be generated.
  • sometimes plugins conflict with each other while using WP hooks. Override all conflicts in the template file: <?php echo apply_filters( 'the_content', get_the_content() ); ?>
  • obviously updating WP core and plugins to the latest version might help as well. No matter how Gutenberg is perspective, it still buggy.

Credit: https://github.com/WordPress/gutenberg/issues/8411



来源:https://stackoverflow.com/questions/56061255/wordpress-5-2-youtube-video-auto-embed-in-posts-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!