Custom shortcode in widget forced to top of widget

For shortcodes you have to return the output for it to be written out where the shortcode appears.

Either turn your HTML into a PHP string rather than breaking out of the PHP tags or you can use PHPs output buffering methods like so:

ob_start();

?>

    <div id="player_<?php echo $id; ?>" class="video_player"><a href="http://www.adobe.com/products/flashplayer/">Get the Flash Player</a> to see this player.</div>

    <script type="text/javascript" src="http://kadampa.org/embed/apps/jwplayer.js"></script> 
    <script type="text/javascript"> 
        jwplayer("player_<?php echo $id; ?>").setup({
            flashplayer: "http://kadampa.org/embed/apps/player.swf",
            playlistfile: "http://kadampa.org/<?php echo $language; ?>/api/video/<?php if ( 'playlist' == 'yes' ) echo 'playlist/'; ?><?php echo $media; ?>/desc",
            height: "<?php echo $height; ?>",
            width: "<?php echo $width; ?>",
            config: "http://kadampa.org/embed/config/<?php echo $style; ?>.xml"
        });
    </script>

<?php

$output = ob_get_contents();
ob_end_clean();

return $output; 

Leave a Comment