Vimeo Shortcode

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

Before starting, here is an overview of the Vimeo Plugin and the shortcodes it provides:

Plugin Icon
Vimeo

"Vimeo Plugin is a powerful tool that integrates seamlessly with your WordPress site, enabling smooth display and management of Vimeo videos directly on your webpages."

★★★★☆ (5) Active Installs: 5000+ Tested with: 6.1.4 PHP Version: 5.6
Included Shortcodes:
  • [vimeo_embed]

Vimeo [vimeo_embed] Shortcode

The Vimeo Embed shortcode is a powerful tool that allows you to embed Vimeo videos directly into your WordPress site. This shortcode uses the Vimeo Embed function to generate a unique ID for each embedded video, ensuring seamless integration and playback. It also allows for customization of video attributes, providing flexibility in presentation and design.

Shortcode: [vimeo_embed]

Parameters

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

  • params – Input array that overrides default settings for the Vimeo video
  • atts – Array that holds default or overridden settings for the Vimeo video
  • id – Unique identifier for each Vimeo video embedded on the page

Examples and Usage

Basic example – A simple usage of the Vimeo Embed shortcode would be to provide the ID of the Vimeo video you want to embed. This example demonstrates how to embed a Vimeo video with the ID ‘123456’.

[vimeo_embed id=123456 /]

Advanced examples

1. Embedding a Vimeo video with custom width and height: In this example, we not only provide the ID of the Vimeo video, but also specify the width and height of the embedded video. The video will be embedded with a width of ‘500px’ and a height of ‘300px’.

[vimeo_embed id=123456 width=500 height=300 /]

2. Embedding a Vimeo video with autoplay: If you want the video to start playing automatically once the page is loaded, you can add the ‘autoplay’ parameter and set it to ‘true’. This example demonstrates how to embed a Vimeo video with the ID ‘123456’ that will autoplay.

[vimeo_embed id=123456 autoplay=true /]

Please note that not all browsers allow autoplay videos, and the user’s settings may also override this parameter.

PHP Function Code

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

Shortcode line:

add_shortcode( 'vimeo_embed', [ new Vimeo_Embed(), 'vimeo_embed'] );

Shortcode PHP function:

function vimeo_embed( $params = [] ) {
		$atts = shortcode_atts( $this->embed->get_defaults(), $params, 'vimeo_embed' );
		$id   = 'vimeo-wc-video-' . uniqid();

		return sprintf(
			'<div style="width: 100%%; min-height: 1px;" id="%s" data-js="vimeo-wc-video" data-atts="%s"></div>',
			esc_attr( $id ),
			esc_attr( wp_json_encode( $atts ) )
		);
	}

Code file location:

vimeo/vimeo/src/Core.php

Conclusion

Now that you’ve learned how to embed the Vimeo Plugin shortcode, 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 *