Forum for discussing general topics related to Couch.
13 posts Page 1 of 2
Is it possible to embed souncloud audio into my blog posts using shortcodes just like we can do for youtube, vimeo and the rest?

If yes, how can that be achieved. Thank you
Code: Select all
$FUNCS->register_shortcode( 'soundcloud', 'soundcloud_handler' );
   function soundcloud_handler( $params, $content=null ){
      global $FUNCS;

      extract( $FUNCS->get_named_vars(array(
         'src' => '',
      ), $params) );

   $html =<<<EOS
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="$src"></iframe>
   return $html

Please place this in your kfunctions.php file along with other shortcode functions.

Code: Select all
 [soundcloud src=""]

Hope it helps.
Not working. The shortcode text rather gets outputted:

Soundcloud.JPG (90.54 KiB) Viewed 359 times
Please refer to the documentation on shortcodes:
Wrap the editable in the do_shortcodes tag like so:
Code: Select all
<cms:do_shortcodes><cms:show my_content /></cms:do_shortcodes>
Yes I have that in place and tested it with a youtube shortcode and it worked correctly.
Code: Select all
[youtube video="yUvBBO5wvuY"]
I ws able to implement the soundcloud shortcode so the raw code does not apppear again but then the soundcloud api does not appear at all. When I looked at the source code this is what I saw:
Code: Select all
<iframe width="100%" height="166" scrolling="no" frameborder="no" src=""></iframe>
My apologies, I made a mistake in my original post (Corrected now).

The parameter defining the URL should be "src". As below:

Code: Select all
[soundcloud src=""]
Thank you very much Bartonsweb. It finally worked but I want to know why this code doesn't work.
Code: Select all
<iframe width="100%" height="450" scrolling="no" frameborder="no" src=";auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>

I copied it from soundcloud's embed. Both the iframe and wordpress code versions do not work
If you want to copy/paste from the "wordpress" embed link, change your kfunctions.php code:

Code: Select all
$FUNCS->register_shortcode( 'soundcloud', 'soundcloud_handler' );
   function soundcloud_handler( $params, $content=null ){
      global $FUNCS;

      extract( $FUNCS->get_named_vars(array(
         'url' => '',
         'height' => '166',
         'width' => '100%',
         'params' => 'color=0066cc',
      ), $params) );
    $src = "$url" . "&amp;" . "$params";
   $html =<<<EOS
<iframe width="$width" height="$height" scrolling="no" frameborder="no" src="$src"></iframe>

   return $html;

You can then copy the wordpress short tag from the embed page:
Code: Select all
[soundcloud url="" params="color=0066cc" width="100%" height="166" iframe="true" /]

Note: This changes the parameter back from "src" to "url", so my last post becomes invalid.
API not showing up on the front-end. When I viewed the page source this was what I saw:
Code: Select all
<iframe width="100%" height="166" scrolling="no" frameborder="no" src=";color=ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false"></iframe>

But nothing appears on the front-end. What could be wrong?
13 posts Page 1 of 2

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests