Check specific "text" from a Custom Field and output it, or else do something..
-
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 URLSo, 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 "https://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 "https://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
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Check specific "text" from a Custom Field and output it, or else do something..’ is closed to new replies.