Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

 <?php
    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>
                </div>
                <div style="clear:both"></div>';

                    }
        add_shortcode('youtube', 'youtube');

    ?>
share|improve this question

1 Answer 1

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 –  m0r7if3r Jan 28 '12 at 17:59

Your Answer

 
discard

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.