如果ashortcode 您可以使用它来构建用于嵌入的soundcloud url,这并不太费劲。
add_shortcode(\'soundcloud_auto\', \'soundcloud_auto_shortcode\');
function soundcloud_auto_shortcode($atts) {
global $post;
$title = str_replace(" ", "", $post->post_title);
$title = str_replace("-", "", $title);
$title = str_replace("_", "", $title);
$slug = sanitize_title($title, str_replace("-", "", $post->post_name));
return wp_oembed_get(esc_url("http://soundcloud.com/$slug"));
}
或者使用
the_content 钩
add_filter(\'the_content\', \'add_soundcloud\');
function add_soundcloud($content){
global $post;
$title = str_replace(" ", "", $post->post_title);
$title = str_replace("-", "", $title);
$title = str_replace("_", "", $title);
$slug = sanitize_title($title, str_replace("-", "", $post->post_name));
return $content . wp_oembed_get(esc_url("http://soundcloud.com/$slug"));
}
The
API 可能是一条更干净的路线。