百度 | 神马 | 搜狗 | 技术文档 | 学习资料分享 - 记录帝国CMS及运维技术的点点滴滴
你的位置:首页 > 实用IT技术 » 正文

【Wordpress相关】WordPress 技巧:禁用 Auto Embeds (oEmbed)

发布时间:2020-09-17

作品分类:Wordpress相关  插件  禁用  激活  禁用  技巧  WordPress  oEmbed  Embeds

WordPress 技巧:禁用 Auto Embeds (oEmbed),

,为了使得后台 UI 和体验更加简洁,就把一些不太常用的选项给隐藏,不让用户设置,防止用户思考和迷惑,其中 WordPress 2.9 引进的 aAuto Embeds 的选项就取消。

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>

WordPress Embeds

默认就是激活状态,但是我们知道 支持的网站大部分都是国外的网站,对于我们用处也不大,如果我们想禁用 Auto Embeds (oEmbed) 功能怎么办呢?

我们发现在 WP_Embed Class 中的构造函数中有如下的 filter:


add_filter( 'the_content', array( $this, 'autoembed' ), 8 );

所以我们只需要把这个 fliter 删除即可,但是我们不能使用 $this 这个变量,需要用到 $wp_embed 这个全局变量:


// Disable auto-embeds for WordPress >= v3.5
remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );

代码自然贴到当前主题的 functions.php 文件或者自己加个插件头,上传到插件目录,激活即可。

该功能已经整合到 插件中,现已免费提供下载,你只需要勾选下就可以移除!


本站推荐使用的主机:,国外主机建议使用

Top