search
HomeCMS TutorialWordPressDetailed explanation of how to use WordPress's own short code to add videos

The following tutorial column of WordPress will 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"】

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 . '】');

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】');

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】');

Set the video height and width

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

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!

Statement
This article is reproduced at:zmingcx. If there is any infringement, please contact admin@php.cn delete
How scalable is WordPress as a CMS for large websites?How scalable is WordPress as a CMS for large websites?May 12, 2025 am 12:08 AM

WordPresscanhandlelargewebsiteswithcarefulplanningandoptimization.1)Usecachingtoreduceserverload.2)Optimizeyourdatabaseregularly.3)ImplementaCDNtodistributecontent.4)Vetpluginsandthemestoavoidconflicts.5)ConsidermanagedWordPresshostingforenhancedperf

How customizable is WordPress, really?How customizable is WordPress, really?May 11, 2025 am 12:11 AM

WordPress is very customized, providing a wide range of flexibility and customizability. 1) Through the theme and plug-in ecosystem, 2) use RESTAPI for front-end development, 3) In-depth code level modifications, users can achieve a highly personalized experience. However, customization requires mastering technologies such as PHP, JavaScript, CSS, etc., and pay attention to performance optimization and plug-in selection to avoid potential problems.

What are the core features of WordPress as a CMS?What are the core features of WordPress as a CMS?May 10, 2025 am 12:15 AM

WordPressisanexcellentchoiceforaCMSduetoitsuser-friendlyinterface,extensiveecosystem,SEOcapabilities,scalability,andsupportivecommunity.1)Itsintuitivedashboardmakescontentmanagementeasyforallusers.2)Thevastarrayofthemesandpluginsallowsforextensivecus

How easy is it to manage content with WordPress?How easy is it to manage content with WordPress?May 09, 2025 am 12:11 AM

WordPressisuser-friendlyduetoitsintuitiveinterfaceandCMS,whichseparatescontentfromdesign.Itoffersarichtexteditorforeasycontentcreationandamedialibraryfororganization.Itsflexibilityisenhancedbynumerousthemesandplugins,thoughoverusecanimpactperformance

How is WordPress used in business settings?How is WordPress used in business settings?May 08, 2025 am 12:04 AM

WordPressissuitableforbusinesssettings.1)Itsupportse-commercewithpluginslikeWooCommerce,allowingproductmanagementandpaymentprocessing.2)ItservesasaCMSforcorporateblogs,enhancingSEOandengagement.3)Customizationispossiblewithnumerousthemesandplugins.4)

What types of websites are not a good fit for WordPress?What types of websites are not a good fit for WordPress?May 07, 2025 am 12:10 AM

WordPressisnotidealforhigh-trafficwebsites,customandcomplexapplications,security-sensitiveapplications,real-timedataprocessing,andhighlycustomizeduserinterfaces.Forhigh-trafficsites,useNext.jsorcustomsolutions;forcomplexapplications,optforDjangoorRub

Can you build a blog with WordPress?Can you build a blog with WordPress?May 06, 2025 am 12:03 AM

Yes,youcanbuildablogwithWordPress.1)ChoosebetweenWordPress.comforbeginnersorWordPress.orgformorecontrol.2)Selectathemetopersonalizeyourblog'slook.3)Usepluginstoenhancefunctionality,likeSEOandsocialmediaintegration.4)Customizeyourthemewithsimplecodetw

How secure is WordPress as a CMS platform?How secure is WordPress as a CMS platform?May 05, 2025 am 12:01 AM

WordPresscanbesecureifmanagedproperly.1)KeeptheWordPresscoreupdatedtopatchvulnerabilities.2)Vetandupdatepluginsandthemesfromreputablesources.3)Enforcestrongpasswordsandusetwo-factorauthentication.4)Chooseahostingproviderwithgoodsecuritypractices.5)Ed

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools