echo do_shortcode is not working on theme’s template

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

<?php 
$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; 
?>

    <li>
    <h3><a href = "https://wordpress.stackexchange.com/questions/70191/<?php the_permalink();?>"><?php the_title();?></a></h3>
    <?php the_post_thumbnail(); ?>                          
    <p> 
    <?php the_excerpt();?>
    <?php                                       
    $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"]');
    ?>          

    </p>
    </li>

<?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

2 Answers
2

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"]');

Leave a Comment