尝试使用oEmbed获取提供的URL的嵌入HTML。
原型
wp_oembed_get( string $url, array $args = '' )
参数
$url
(string)
(Required)
应嵌入的URL。
$args
(array)
(Optional)
用于检索嵌入HTML的其他参数和参数。
返回值
(false|string)
失败时失败或嵌入HTML成功。
源文件
路径:wp-includes/embed.php
<?php
...
function wp_oembed_get( $url, $args = '' ) {
$oembed = _wp_oembed_get_object();
return $oembed->get_html( $url, $args );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_oembed_get/