JW Player for WordPress Shortcodes

Below, you’ll find a detailed guide on how to add the JW Player for WordPress Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the JW Player for WordPress Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the JW Player for WordPress Plugin and the shortcodes it provides:

Plugin Icon
JW Player for WordPress

"JW Player for WordPress is a powerful plugin that allows seamless integration of the JW Player into your WordPress site. Enhance your media capabilities with this easy-to-use tool."

★★★☆✩ (28) Active Installs: 3000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [jw7-video]
  • [jwplayer]

JW Player for WordPress [jw7-video] Shortcode

The JW Player 7 for WP shortcode allows you to embed a video player into your posts. The ‘jwppp_player_s_code’ function is called, which sets up the video player with specified parameters. These parameters include the post ID, video number, aspect ratio, width, height, autostart, mute, and repeat options. By using this shortcode, you can easily customize the JW Player’s settings for each instance on your site.

Shortcode: [jw7-video]

Parameters

Here is a list of all possible jw7-video shortcode parameters and attributes:

  • p – The ID of the post where the video is hosted
  • n – The number of the video in a playlist
  • ar – Aspect ratio of the video player
  • width – Width of the video player
  • height – Height of the video player
  • pl_autostart – If set, the video starts playing automatically
  • pl_mute – If set, the video starts playing in mute mode
  • pl_repeat – If set, the video will repeat after finishing

Examples and Usage

Basic example – A simple usage of the jw7-video shortcode to display a video from the current post.

[jw7-video p="1" /]

Advanced examples

Using the shortcode to display a video with specified width and height. This example also sets the video to autoplay, mute, and repeat.

[jw7-video p="1" width="640" height="360" pl_autostart="true" pl_mute="true" pl_repeat="true" /]

Another advanced usage of the shortcode to display a specific video from a post by using the ‘n’ attribute. This example also sets the aspect ratio of the video.

[jw7-video p="1" n="2" ar="16:9" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [jw7-video] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'jw7-video', 'jwppp_player_s_code' );

Shortcode PHP function:

function jwppp_player_s_code( $var ) {
	ob_start();
	$video = shortcode_atts(
		array(
			'p'      => get_the_ID(),
			'n'      => '1',
			'ar'     => '',
			'width'  => '',
			'height' => '',
			'pl_autostart' => '',
			'pl_mute'     => '',
			'pl_repeat'   => '',
		),
		$var
	);
	jwppp_player_code(
		$video['p'],
		$video['n'],
		$video['ar'],
		$video['width'],
		$video['height'],
		$video['pl_autostart'],
		$video['pl_mute'],
		$video['pl_repeat']
	);
	$output = ob_get_clean();
	return $output;
}

Code file location:

jw-player-7-for-wp/jw-player-7-for-wp/includes/jwppp-functions.php

JW Player for WordPress [jwplayer] Shortcode

The JW Player 7 for WP plugin shortcode is a tool that allows you to embed a JW player into your WordPress posts or pages. It initiates the ‘jwppp_old_player_s_code’ function, which checks if a file is specified and then generates the player code for that file. If no file is specified, it won’t generate any output.

Shortcode: [jwplayer]

Parameters

Here is a list of all possible jwplayer shortcode parameters and attributes:

  • [0] – the first value of the shortcode parameter array
  • file – the file URL or path to be used by the JW Player

Examples and Usage

Basic example – Displays a JW player with the video file specified in the shortcode.

[jwplayer file="my-video.mp4" /]

Advanced examples

Using the shortcode to display a JW player with a video file specified by its index in an array. The video will be loaded based on its position in the array.

[jwplayer 0 /]

Using the shortcode to display a JW player with a video file specified by its name. The video will be loaded based on its file name.

[jwplayer file="my-second-video.mp4" /]

Note: In the above examples, replace “my-video.mp4” and “my-second-video.mp4” with the actual names of your video files.

PHP Function Code

In case you have difficulties debugging what causing issues with [jwplayer] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'jwplayer', 'jwppp_old_player_s_code' );

Shortcode PHP function:

function jwppp_old_player_s_code( $vars ) {

    $var    = null;
    $output = null;

    if ( isset( $vars[0] ) ) {

        $var = $vars[0];

    } elseif ( isset( $vars['file'] ) ) {

        $var = $vars['file'];

    }

    if ( $var ) {

        ob_start();

        jwppp_simple_player_code( $var );

        $output = ob_get_clean();

    }

	return $output;
}

Code file location:

jw-player-7-for-wp/jw-player-7-for-wp/includes/jwppp-functions.php

Conclusion

Now that you’ve learned how to embed the JW Player for WordPress Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *