WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Hi all I've created a function that basically allows the user to input the embed code for youtube into a custom field called youtube and this will then be styled on a wordpress post. Now I can get it to work perfectly until I want to wrap some CSS around it. Could you have a look where I'm going wrong. I think it's because I'm closing and opening PHP code? Thanks

    function youtube(){
        $ytvalue = get_post_custom_values("youtube");
        $youtube = $ytvalue[0]; 
        return '<div class="youtubeVideoWrapper">
                <div class="youtubeVideoHeader"></div>
                <div style="clear:both"></div>  
                <div class="youtubeVideoOuterContainer">
                <div class="youtubeVideoInnerContainer">';

        return $youtube;

        return '</div>
                <div style="clear:both"></div>';

        add_shortcode('youtube', 'youtube');

share|improve this question
up vote 0 down vote accepted

Your function is going to hit the end of that first return and stop. Concatenate the strings and it should start working.

share|improve this answer
Update - Ignore the comment below sorted it with google and your help thanks very much :)Hi thanks yeh I just read the code will stop executing after the first return. Any chance you could show me how to concatenate the strings? It's a term im very unfamiliar with. – Mark Jan 28 '12 at 17:50
Concatenation is as simple as using the concatenation operator, which is just .. So say that I have two strings $foo = 'string' and $bar = 'concatenation', $foo . $bar would be stringconcatenation and $foo . ' ' . $bar would be string concatenation – mor7ifer Jan 28 '12 at 17:59

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.