Aparat Shortcode

Below, you’ll find a detailed guide on how to add the Aparat 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 Aparat Plugin shortcode not to show or not to work correctly.

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

Plugin Icon
Aparat

"Aparat is a versatile WordPress plugin designed to seamlessly integrate your website with Aparat video sharing services. With its user-friendly interface, you can easily embed and manage Aparat videos."

★★★★✩ (14) Active Installs: 5000+ Tested with: 6.1.4 PHP Version: false
Included Shortcodes:
  • [aparat]

Aparat [aparat] Shortcode

The Aparat shortcode is designed to embed Aparat videos into your WordPress site. It allows customization of video dimensions and style. . The shortcode uses the ‘id’ attribute to specify the video. ‘Width’ and ‘height’ set the video size, while ‘style’ adjusts the margin.

Shortcode: [aparat]

Parameters

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

  • id – The unique video ID from Aparat’s platform.
  • width – Determines the width of the video frame, default is 100%.
  • height – Sets the height of the video frame, default is 450.
  • style – Adds custom CSS styles to the video frame, default is ‘margin: 15px 1px 10px 1px;’

Examples and Usage

Basic example – Here’s how you can use the Aparat shortcode to embed a video on your website. This example uses the video’s unique id as a parameter.

[aparat id='12345' /]

Advanced examples

Customizing the size of the embedded video – In this example, we are specifying the width and height of the video. The width is set to 50% of the container’s width and the height is set to 300 pixels.

[aparat id='12345' width='50%' height='300' /]

Applying custom styles to the video – You can also apply custom styles to the video using the ‘style’ parameter. In this example, we are changing the video’s margin.

[aparat id='12345' style='margin: 20px 0px 10px 0px;' /]

Using multiple parameters – You can also use multiple parameters at once. This example shows how to use the id, width, height, and style parameters together.

[aparat id='12345' width='50%' height='300' style='margin: 20px 0px 10px 0px;' /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'aparat', 'aparat' );

Shortcode PHP function:

function aparat($atts) {
		//$atts = str_replace("’", "", $atts);
		extract( shortcode_atts( array(
			'id' => '',
			'width' => '100%',
			'height' => 450,
			'style' => 'margin: 15px 1px 10px 1px;'
		), $atts ) );
		$id = str_replace("’", "", $id);
		return "<center style='{$style}'><iframe src='".(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http')."://www.aparat.com/video/video/embed/videohash/{$id}/vt/frame' width='{$width}' height='{$height}' allowfullscreen='true' style='border:none!important'></iframe></center>";
	}

Code file location:

aparat/aparat/index.php

Conclusion

Now that you’ve learned how to embed the Aparat 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 *