How to replace featured image with embedded video

PHP Code Snippets/Functions

Requirements:

  • ACF fields
  • functions.php
  • youtube embedded url, local video is fine also.

Step 1: Create an acf field for your video embed. In this tutorial we will add “video_embed” for our video embed and “enable_autoplay” for enabling autoplay.

note: we have added an autoplay because the client for this code requested if its possible to have a switch that disable or enabled the autoplay feature.

note: erase the #1 custom field since that field is irrelevant in this tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *