Support » Plugin: JW Player for Flash & HTML5 Video » Shortcode is not working in custom field

  • Hi,

    It just today that jwplayer shortcode has stopped working. I’m using free version JW Player 2.0.5 with JW6 enabled.

    I noticed shortcode only works in the post content but not in the custom field. BTW, I’m using advanced custom field plugin to load the player. We have no problem adding other plugins’ shortcodes into the custom field.

    I tried to manually execute do_shortcode(“[jwplayer config=”Video” mediaid=”5385″]”) function into the template file but no player is displayed.

    Adding the same shortcode into the post content works fine.

    I ended up calling the method that executes to add the shortcode. I added the code below into the theme functions.php and seems it fixed the problem:

    `add_shortcode(‘jwplayer’, ‘JWP6_Plugin::shortcode’ );’

    I’m not sure if it’s a bug or I missed other configuration to make the player working.

    Great job!

    Please let me know and thanks in advanced.


Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author JW Player


    The JW Player uses its own shortcode parser. This is because of legacy reasons, but also because support for shortcodes in the_excerpt is limited. You can play with shortcode settings in the settings menu of the plugin. You can also toggle the setting in jwplayermodule.php (see lines 33-45). This allows you to enable the regular shortcode, but please note that we do not test this functionality with each release.

    Okay, changing ‘JWP6_USE_CUSTOM_SHORTCODE_FILTER’ to ‘false’ from jwplayermodule.php will fix the issue as well. When a new version is available should I need to redo the changes of the file? Is it possible to add an option in the settings whether to use custom shortcode or not in the future release?

    Thanks for your help.

    Plugin Author JW Player


    Yes, you nee to redo the changes after an upgrade and no it will not become a setting in the near future, because it is not officially supported. When starting on the development of the JW6 plugin we started with the regular shortcode API, however this broke many themes, so we went back to the custom parser of the JW5 plugin. The other option was left in, but is not/no longer supported.

    Thanks for the response.

    We have decided to revert back to JW5 so player won’t have a logo/watermark, however, but we’ve ran into some problem because shortcode is not working in custom meta box anymore.

    I’ve looked at the way you handle the shortcode and I think I’ve found the issue and I’ve fixed it by adding the codes into my functions.php:

    function jwplayer5_fix( $jwvideo ) {
    	$execute = true;
    	if ( $jwvideo ) :
    		$tag_regex = '/(.?)\[(jwplayer)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s';
    		if ($execute) {
    			$the_video = preg_replace_callback($tag_regex, "jwplayer_tag_parser", $jwvideo);
    		} else if($disable) {
    			$the_video = preg_replace_callback($tag_regex, "jwplayer_tag_stripper", $jwvideo);
    		echo $the_video;

    In my template, I call the function like this:

    jwplayer5_fix( get_field('video') );

    I’m not exactly sure if this is the permanent fix. Let me hear your thoughts about the issue.

    Thanks again.

    Plugin Author JW Player


    Thank you for thinking along, but the JW player plugin for version 5 will no longer be updated. All work will go into version 6.

    Is it possible to add an option in the settings whether to use custom shortcode or not in the future release?

    Yes, you nee to redo the changes after an upgrade and no it will not become a setting in the near future, because it is not officially supported

    What is the problem with adding a simple setting in the plugin admin if it solves the problem? If you won’t do that, how about at least making the function filterable so that we can make the change in our theme functions file or custom plugin? Afterall, that’s pretty much how all of WordPress is built…

    Do you have a better solution for getting jwplayer shortcodes to work in custom fields?

    Plugin Author JW Player


    The problem is support. Each option can break and each plugin needs to be tested in multiple browsers with multiple versions of WordPress and with some other popular plugins/themes.

    Adding a setting like this would dramatically increase the amount of time needed for testing. As a middle road we have chosen to keep it like this. If should work and it is basically tested only with the latest version of WordPress in one browser, but it is no supported.

    If WordPress had an official way of releasing beta versions of plugins, we could crowdsource testing with those willing to use the beta, but unfortunately this is not yet possible in an easy way.



    I’m having the same issue with JW Player 6 shortcode through custom fields, all I see is the shortcode, yet if I place it in the content description of the post, it works fine, good thing there’s a free version to try it out first, there has to be a way to push the shortcode through custom fields, I wouldn’t mind upgrading to a license version, please consider a workaround or a temporary fix at least, even if it involves implementing additional code in the core templates, i can really use some help here.

    Plugin Author JW Player


    What plugin are you using for these custom fields?



    There’s no plugin involved, its actually part of the Theme, the custom fields are mainly custom meta boxes and created manually by the admin and the end user can place dynamic content within, although it seems that those custom fields dont support shortcodes.

    I tried Eugene’s approach and that didnt work either. I’m looking for a way to include code in the core post-loop template to allow the translation of a shortcode and to output the JW player as if I had inserted the shortcode in the Description field of the post where it works well.

    Plugin Author JW Player


    Can you provide an example of where you tried that approach?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Shortcode is not working in custom field’ is closed to new replies.