你应该add a filter on oembed provider 要允许自定义参数,请执行以下操作:
add_filter( \'oembed_fetch_url\', \'my_oembed_fetch_url\', 10, 3 );
function my_oembed_fetch_url( $provider, $url, $args ) {
// You can find the list of defaults providers in WP_oEmbed::__construct()
if ( strpos( $provider, \'vimeo.com\' ) !== false) {
// Check the full list of args here: https://developer.vimeo.com/apis/oembed
if ( isset( $args[\'autoplay\'] ) ) {
$provider = add_query_arg( \'autoplay\', absint( $args[\'autoplay\'] ), $provider );
}
if ( isset( $args[\'color\'] ) && preg_match( \'/^[a-f0-9]{6}$/i\', $args[\'color\'] ) ) {
$provider = add_query_arg( \'color\', $args[\'color\'], $provider );
}
if ( isset( $args[\'portrait\'] ) ) {
$provider = add_query_arg( \'portrait\', absint( $args[\'portrait\'] ), $provider );
}
if ( isset( $args[\'title\'] ) ) {
$provider = add_query_arg( \'title\', absint( $args[\'title\'] ), $provider );
}
if ( isset( $args[\'byline\'] ) ) {
$provider = add_query_arg( \'byline\', absint( $args[\'byline\'] ), $provider );
}
}
return $provider;
}
然后,在模板中:
<?php wp_oembed_get(\'http://vimeo.com/44633289\', array(\'color\' => \'7AB800\')); ?>
或通过
shortcode 在帖子内容中:
[vimeo 44633289 color=7AB800]
你也可以对youtube和所有其他oembed提供商(如果你的
my_oembed_fetch_url
允许它)