
It’s come from another post format I made in my tumblog theme. I’ve add a custom meta box in post editor to easily deal with the post format. Firstly, there’s a text input for audio URL and a textarea for SoundCloud embed code. I thought that’s not an effective way to solve this problem. I want just a text input for both audio URL or SoundCloud URL.
I looking for another way more effective and found built-in WordPress function, wp_oembed_get(). But I realized that the built-in library in WordPress doesn’t support SoundCloud oEmbed yet. Here the function wp_oembed_add_provider() works.
// Register oEmbed support for Soundcloud wp_oembed_add_provider( 'http://soundcloud.com/*', 'http://soundcloud.com/oembed' );
The first argument, http://soundcloud.com/* is the URL structure that this (SoundCloud) oEmbed provider supports. The second, http://soundcloud.com/oembed is the base URL of the oEmbed provider. Actually there’s third argument, regex, but we doesn’t need it this time.
Here is the example of post custom meta data:
// Get the URL from custom field
$audio = get_post_meta($post->ID, 'daoon_audio', true);
// Echo the embedded sound
if ($audio)
echo wp_oembed_get($audio);
And lastly, we just paste the SoundCloud track URL to the meta box and it automatically embedded. One thing I didn’t find the way is how we add a parameter to the embedded URL without entering it directly in the box. There’s an array argument after the URL at wp_oembed_get(), but I tried and it doesn’t work. Anyone knows, please leave at comment, thanks.
This he quickly load it Riz
Sorry for not replying yesterday
some of my friends said its light load too, hehe
just another comment XD
layout blog keren…btw ini pake font droid sans bukan?
thanks.. yup, I used Droid Sans and Gleego..
how about video tag html5 from youtube?
As I know, you just need to paste the video URL and WordPress do the rest for you. In case its not, check media settings on your dashboard which state enable auto embeds.
naturally like your web site however you need to take a look at the spelling on quite a few of your
posts. Many of them are rife with spelling issues and I to
find it very troublesome to inform the truth nevertheless I’ll certainly come back again.
Thanks and so sorry for my English. Of course I’ll take a look at those points.