Ask your WordPress questions! Pay money and get answers fast! (more info)

JW Player shortcode not working in custom meta box WordPress


I'm trying to embed a video using JW Player on my site. The site is a template and the functions.php is encrypted but I can make all changes that I need in theme-functions.php which is in the includes folder.

JW Player plugin is installed and it is working. I use the shortcode provided by JW Player in the_content and it parses as it should. The only place it doesn't work is in the custom meta box. I need the custom meta box to parse this. Since the functions.php file is encrypted, looking at the singles.php file tells me the input field is named "videoswiper-embed-code".

I have tried this without success:

echo apply_filters('the_content', get_post_meta($post->ID, 'videoswiper-embed-code', true));

which I would rather not do because I don't want to apply all those filters to the input field.


echo do_shortcode('videoswiper-embed-code');

This second option seems more reasonably but produces nothing.

I have also tried both of these with '$videoswiper-embed-code' (with the dollar sign) because I'm not too familiar with the syntax.

Answers (2)


Martin Pham answers:

please try this
insert to functions.php

add_filter( 'videoswiper_embed', 'do_shortcode', 10 );
add_shortcode('videoswiper-embed-code', 'videoswiper_embed_code');
function videoswiper_embed_code() {
global $post;
$video_meta = get_post_meta($post->ID, 'videoswiper-embed-code', true);
$output = sprintf('<div class="videoswiper-embed">%s</div>', apply_filters( 'videoswiper_embed', $video_meta ));
return $output;


echo do_shortcode('videoswiper-embed-code');

[[LINK href=""]]phim[[/LINK]]

Karlo Rihoo comments:

Tried it. It doesn't work. If I include

echo do_shortcode('videoswiper-embed-code');

It gives me a <blockquote>videoswiper-embed-code Warning: Cannot modify header information </blockquote> error on some pages and prints out 'videoswiper-embed-code' on the top of other pages.

If I don't include it, it still doesn't parse it.

Martin Pham comments:

sr, please using

echo do_shortcode('[videoswiper-embed-code]');

You can also use it in the text editor. If you continue to receive warnings, please let me know you're using jwplayer plugin version?