Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggreagtion Enquires Welcome

Embed an Omny.fm Audio Player With WordPress Shortcode

Omny.fm is a high-end podcast and audio hosting service with integrated player analytics. It's a premium service typically used by radio stations and other audio professionals because of a range of features that permits editing, live cloud capture, and audience analytics. While not typically used by your everyday podcaster, there are times when you might integrate the player into your WordPress website, and this article provides the necessary code to achieve that end.

As with any embed code, shortcode is almost always a better alternative to raw embed code because of the ease of which global player changes can be made (changing the shortcode alters each occurrence of the player on your website).

The Result

I've referenced an audio clip from Alan Jones' radio program in our examples (and for no particular reason except it was the first I found). I've also truncated the URL for page formatting purposes.

The player renders in three flavours:

artwork (default)

Shortcode of [omny url="https://omny.fm/show .. d-with"] returns the following:

[omny url="https://omny.fm/shows/the-alan-jones-breakfast-show/cory-bernardi-halal-certification-is-riddled-with"]

cover

Shortcode of [omny url="https://omny.fm/show .. d-with" style="cover"] returns the following:

[omny url="https://omny.fm/shows/the-alan-jones-breakfast-show/cory-bernardi-halal-certification-is-riddled-with" style="cover"]

square

Shortcode of [omny url="https://omny.fm/show .. d-with" style="square"] returns the following:

[omny url="https://omny.fm/shows/the-alan-jones-breakfast-show/cory-bernardi-halal-certification-is-riddled-with" style="square"]

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
    Embed an Omny.fm Audio Player With WordPress Shortcode
4
    <blockquote class="wp-embedded-content" data-secret="0eU1VGeOkS"><a href="https://www.beliefmedia.com.au/embed-omnyfm-wordpress">Embed an Omny.fm Audio Player With WordPress Shortcode</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Embed an Omny.fm Audio Player With WordPress Shortcode” — BeliefMedia Finance & Mortgage Broker Digital Marketing" src="https://www.beliefmedia.com.au/embed-omnyfm-wordpress/embed#?secret=0eU1VGeOkS" data-secret="0eU1VGeOkS" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
5
*/
6
 
7
 
8
function beliefmedia_omnyfm_player($atts) {
9
 
10
  $atts = shortcode_atts(array(
11
    'url' => '', /* Omny.fm Clip URL */
12
    'width' => '540',
13
    'style' => 'artwork' /* artwork, cover, or square */
14
  ), $atts);
15
 
16
  /* URL Required */
17
  if ($atts['url'] == '') return '<p>The omny.fm audio URL is required.</p>';
18
 
19
  /* Adjust standard heights & style */
20
  $style = ($atts['style'] == 'square') ? 'cover&size=square' : $atts['style'];
21
  $height = ($atts['style'] == 'square') ? $atts['width'] : '180';
22
 
23
 return '<p><div style=&quot;text-align: center; max-width:' . $width . ';&quot;><iframe src=&quot;' . rtrim($atts['url'], '/') . '/embed?style=' . $style . '&quot; frameborder=&quot;0&quot; width=&quot;' . $atts['width'] . '&quot; height=&quot;' . $height . '&quot;></iframe></div></p>';
24
}
25
add_shortcode('omny', 'beliefmedia_omnyfm_player');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes

The following attributes are available to alter the appearance of the player.

url

The page URL of the audio clip.

width

We've wrapped the player in a container to avoid the player stretching to 100% by default. Alter the width to your liking. If using a square player, the height will inherit your width.

type

Available player types are artwork (default), cover, or square (as shown above)

Considerations

Omny has an API that provides some seriously funky features . We'll be sharing some features of the API sometime soon via the tag of omny Tag: omny

Download

Invalid Download Record [E1].

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment

READY TO HAVE A CHAT? CALL US ANYTIME ON 1300 235 433