Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

​ uses the method of adding video with short code in WordPress

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the use of WordPress with short code to add video method, the article is very detailed, has a certain reference value, interested friends must finish!

Use WordPress to add video with short code

Using the video short code that comes with WordPress, you can easily add videos anywhere. The supported file types are mp4,m4v,webm,ogv,wmv and flv.

Basic video short code

[video src= "pepper.mp4"]

To be replaced by [], the following is the same

Adding to the article will automatically call WordPress's own player.

Use short codes in template files

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

$video_file = get_template_directory_uri (). "/ videos/pepper.mp4"; echo do_shortcode ('[video mp4='. $video_file. ']')

Loop and auto playback

You can loop and auto-play through parameters, and define the class as my-video

Echo do_shortcode ('[video mp4='. $video_file. ' Loop = "on" autoplay = 1 class = my-video]')

Add a video cover (placeholder)

For example, take the cover.jpg image in the (theme directory) / images folder as the cover:

Echo do_shortcode ('[video mp4='. $video_file. ' Poster ='. Get_template_directory_uri (). '/ images/cover.jpg]')

Set the video height and width

Echo do_shortcode ('[video mp4='. $video_file. ' Width = 320 height = 240]); these are all the contents of this article entitled "adding videos with WordPress's own short code". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report