Friday, 28 July 2017

How to Add HTML5 Video to WordPress Using Custom Fields

Generally speaking, if you ask 10 WordPress developers how to do something, you’ll receive ten different answers. But that speaks to both the versatility of the CMS and that there is more than one solution to any given task. Recently, I faced the challenge of setting up an HTML5 video inside a WordPress page. It’s in a static location and would need to be replaced every so often. While it’s fine to use the Video Shortcode, in this case I wanted to make things extra simple for the folks who would be updating the page. I didn’t want them to have to learn what a Shortcode was or how to use it.
So, the simplest solution (in my mind, anyway) was to create some custom fields where the related video files could be uploaded. From there, the theme’s template would automatically create the necessary code to display the video. Here’s how I did it:
Project Requirements
You’ll of course need a WordPress site and access to edit your theme (please use a child theme if you aren’t already doing so). Some familiarity with PHP and HTML will also be a big help. Beyond that, you should have:
A way to create custom fields. The free version of Advanced Custom


No comments:

Post a Comment