公认的答案在我的情况下不起作用。URL仍在post编辑器中转换为嵌入。
通过查看wp-includes/class-wp-embed.php 在处理这些事情时,我发现还有其他一些事情在起作用:
// Hack to get the [embed] shortcode to run before wpautop()
add_filter( \'the_content\', array( $this, \'run_shortcode\' ), 8 );
// Shortcode placeholder for strip_shortcodes()
add_shortcode( \'embed\', \'__return_false\' );
// Attempts to embed all URLs in a post
add_filter( \'the_content\', array( $this, \'autoembed\' ), 8 );
// After a post is saved, cache oEmbed items via AJAX
add_action( \'edit_form_advanced\', array( $this, \'maybe_run_ajax_cache\' ) );
解决这个问题的方法是在我的主题文件中禁用这些,如下所示:
remove_shortcode( \'embed\' );
remove_filter( \'the_content\', [ $GLOBALS[\'wp_embed\'], \'autoembed\' ], 8 );
remove_filter( \'the_content\', [ $GLOBALS[\'wp_embed\'], \'run_shortcode\' ], 8 );
remove_action( \'edit_form_advanced\', [ $GLOBALS[\'wp_embed\'], \'maybe_run_ajax_cache\' ] );