Hi,
So my blog is based on music news and such....
On my custom fields for embedding media. I only allow 2 sources.
- Either Youtube OR a SoundCloud URL
So, i'd like a simple php code that can do this:
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]
<?php
Check post meta (get_post_meta($post->ID, 'my_url_media', true);)
?>
<?php if any meta value exist; (continue)
If post meta contains this string "http://www.youtube";
echo '
<div id="JWPlayer"></div>
<script>
jwplayer("JWPLayer").setup({
file: "'.POST META HERE (YOUTUBE).'",
width: "100%",
height: 30
});
</script>
';
}
ELSE
{
If post meta contains "http://soundcloud"
echo '<iframe src=" POST META HERE (soundcloud)" class="somerandomCSSClass"></iframe>'
?>
If there is no meta value, then do nothing at all.
As you can see, i'm a complete php novice, but at least i know how i'd like the function to work.
So PHP & WP gurus, what do you think ?
Thanks for reading