WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently using CF Post Formats ( http://alexking.org/blog/2011/10/25/wordpress-post-formats-admin-ui ) and using the following code to automatically embed a URL that has been input into the 'Audio' or 'Video' custom field:

<?php echo wp_oembed_get( get_post_meta($post->ID, '_format_audio_embed', true) ); ?>

However, if oembed does not support the service (Eg. Spotify) and the user inputs the full embed code, it does not echo out anything.

How could I get around this so that if the user inserts code starting with something like:


then it won't use Oembed and instead it will display normally?

share|improve this question
up vote 0 down vote accepted

<?php if (strstr($audio, '<iframe')) { echo $audio; } else { echo wp_oembed_get( get_post_meta($post->ID, '_format_audio_embed', true) ); } ?>

Of course, this would require that you get the custom field with the audio embed code or url into $audio :)

Edit - try:

<?php $audio = get_post_meta($post->ID, '_format_audio_embed', true); if (strstr($audio, '<iframe')) { echo $audio; } else { echo wp_oembed_get( $audio ); } ?>

share|improve this answer
Great thanks so much! How would I get the url/audio embed code into $audio ? :-) – user2014024 Feb 28 '13 at 17:05
Try the edit. Let me know if that works for you. (I was a little tired when I answered the first time :) – jfacemyer Mar 1 '13 at 2:09
Works great - thank you for coming back and showing me the other part too! :) – user2014024 Mar 1 '13 at 12:18
No problemo! I realized that the answer was simple enough, and I should have given it completely the first time! – jfacemyer Mar 4 '13 at 3:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.