Search code examples
wordpressvideoarchive

Wordpress - short mp4 video instead of featured image


I want to show short 5 second long videos on loop instead of the featured image on the archive page for each of my blog posts. I'm looking to just to be able to upload the short video(mp4) as the featured image on each post. Can't find anything on google as most posts are about just getting a thumbnail from an uploaded video. Any help would be amazing


Solution

  • actually, you CAN upload mp4 as featured image. but it will not be displayed correctly since the template expects an image and renders an img-tag. create a new archive.php in your child-theme (or whatever you have to overwrite in your theme) to output the correct code for a video. https://www.w3schools.com/tags/tag_video.asp

    however, you are probably better off using a custom field plugin like ACF or Toolset to add a field for featured-video. this way you are more flexible and you can store the thumbnail in featured image as well as the video. simply change the theme templates via child-theme whereever necessary.

    keep in mind that mp4 is NOT supported by all browsers, you should actually generate also an ogg-version and maybe even webm, means 2 or 3 extra custom fields.

    i don't know about ACF, but with Toolset you can overwrite the output of archives as well as post templates easily from the backend.

    alternatively you could use animated gifs without any change to the code.