I don't know whats causing the problem but the echo do_shortcode is not working on my theme's template, but its working on my plugin's template and the shortcode is working on my posts and pages. Pretty weird. Here's the code

$my_query = new WP_Query('category_name=video post&posts_per_page=10');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; 

    <h3><a href = "<?php the_permalink();?>"><?php the_title();?></a></h3>
    <?php the_post_thumbnail(); ?>                          
    <?php the_excerpt();?>
    $urlbox = get_video_box();

    echo $urlbox[0]; // echo out the url of a post                     
    echo $urlbox[1]; // echo out the url description of a post
    echo do_shortcode('[jwplayer config="Out-of-the-Box" file="' . $urlbox[0] . '" image="http://www.mywebsite.com/myimage.jpg"]');


<?php endwhile; ?>  

I am using the JW player plugin, again, the shortcode is working on the plugin's template and post/page . but on my theme's template its not working.. please help me here. Thanks

  • Can you provide a link to your website? It's possible that there could be conflicting scripts on that particular page. – Nicole Oct 23 '12 at 14:08
  • Has the hook with which you add the shortcode run when the theme template is loaded? – Johannes Pille Oct 23 '12 at 14:32
  • I don't know how but after deactivating and reactivating plugins, the code is now working. Anyway, Thanks Guys. :) – markyeoj Oct 23 '12 at 15:18
  • I have the same issue with do_shortcode() and jwPlayer in my theme. – david Nov 2 '12 at 17:44

According to the developer of the jwPlayer it was necessary to implement the plugin as a filter to be able to support '.' in tag attributes. Hence do_shortcode(..) does not work but jwplayer_tag_callback(..) will return the desired result.

Matching your example simply execute:

echo jwplayer_tag_callback('[jwplayer config="Out-of-the-Box" file="' . $urlbox[0] . '" image="http://www.mywebsite.com/myimage.jpg"]');

Update for everyone visiting this thread (2015)

jwplayer_tag_callback() does not work anymore, you'll get a fatal error telling you the function is not defined.

Instead insert a player programmatically like this:

echo JWP6_Shortcode::the_content_filter( '[jwplayer file="'. $videoUrl .'"]' );

(Found here.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.