原因why 这正在发生,似乎可以在文件中找到wp-includes/class-wp-embed.php 在autoembed 回拨方式:
/**
 * Passes any unlinked URLs that are on their own line to {@link WP_Embed::shortcode()} for potential embedding.
 *
 * @uses WP_Embed::autoembed_callback()
 *
 * @param string $content The content to be searched.
 * @return string Potentially modified $content.
 */
function autoembed( $content ) {
    return preg_replace_callback( \'|^\\s*(https?://[^\\s"]+)\\s*$|im\', array( $this, \'autoembed_callback\' ), $content );
}
 在哪里
// Attempts to embed all URLs in a post
add_filter( \'the_content\', array( $this, \'autoembed\' ), 8 );
 据我所知,匹配行必须只包含一个链接,该链接可以由链接前后的任意数量的空格字符包装。
所以这个模式会排除这条线:
<p>http://www.youtube.com/watch?v=xxxxxxxxxxx</p>
 您可以尝试添加自己的
the_content 在链接周围的段落标记内的链接前后添加新行的过滤器。这应该在
autoembed 筛选器已执行,因此它的优先级应为
8.
过滤器示例:
你可以在这个伟大的在线工具中使用正则表达式:
http://regexr.com?36eat
在插入图案的位置:
^<p>\\s*(https?://[^\\s"]+)\\s*</p>$
 更换后:
<p>\\n$1\\n</p>
 您可以根据需要进行调整。
以下是此类自定义过滤器的一个想法:
add_filter( \'the_content\', \'my_autoembed_adjustments\', 7 );
/**
 * Add a new line around paragraph links
 * @param string $content
 * @return string $content
 */
function my_autoembed_adjustments( $content ){
    $pattern = \'|<p>\\s*(https?://[^\\s"]+)\\s*</p>|im\';    // your own pattern
    $to      = "<p>\\n$1\\n</p>";                          // your own pattern
    $content = preg_replace( $pattern, $to, $content );
    return $content;
}