Home> CMS Tutorial> WordPress> body text

Detailed explanation of how to use WordPress's own short code to add videos

藏色散人
Release: 2021-04-09 19:25:31
forward
3513 people have browsed it

The following tutorial column ofWordPresswill introduce to you how to add videos using the short code that comes with WordPress. I hope it will be helpful to friends in need!

Detailed explanation of how to use WordPress's own short code to add videos

Use WordPress’s built-in short code to add videos

Using WordPress’s built-in video short code allows you to easily add videos anywhere Location to add videos, supported file types are mp4, m4v, webm, ogv, wmv and flv.

Detailed explanation of how to use WordPresss own short code to add videos

Basic video short code

【video src="pepper.mp4"】
Copy after login

Replace [] with [], the following same

will be automatically called when added to the article WordPress comes with a player.

Using shortcodes in template files

You can use the do_shortcode() function to call the video in the theme template. If the video file is stored in your theme directory, use get_template_directory_uri() or get_stylesheet_uri() Get the file url directly.

$video_file = get_template_directory_uri() . "/videos/pepper.mp4"; echo do_shortcode('【video mp4=' . $video_file . '】');
Copy after login

Looping and automatic playback

Looping and automatic playback can be achieved through parameters, and the class is defined as my-video

echo do_shortcode('【video mp4=' . $video_file . ' loop = "on" autoplay = 1 class = my-video】');
Copy after login

Add video cover (placement image)

If you use the cover.jpg picture in the (theme directory)/images folder as the cover:

echo do_shortcode('【video mp4=' . $video_file . ' poster = ' . get_template_directory_uri() . '/images/cover.jpg】');
Copy after login

Set the video height and width

echo do_shortcode('【video mp4=' . $video_file . ' width = 320 height = 240】');
Copy after login

More

The above is the detailed content of Detailed explanation of how to use WordPress's own short code to add videos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:zmingcx.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!