This code snippet allows you to set a video as the featured video for any post type in WordPress. By default, WordPress allows you to set a featured image for posts, but with this code, you can extend this functionality to include videos.
-
Copy the code snippet provided in this README.
-
Navigate to your WordPress admin panel. Go to Appearance > Theme Editor.
-
In the Theme Files section, locate and click on the "functions.php" file.
-
Paste the copied code snippet at the end of the functions.php file.
-
Save the changes.
After adding the code snippet to your theme's functions.php file, follow these steps to set a video as the featured video for a post:
-
Create or edit a post of any post type (e.g., post, page, custom post type).
-
Scroll down to the featured video meta box below the content editor.
-
Click on the "Set featured video" button.
-
A modal will appear where you can insert the URL of the video you want to set as the featured video.
-
Paste the URL of the video (YouTube, Vimeo, or any supported video platform) and click "Set as featured video."
-
Save or update the post.
Supports videos from YouTube, Vimeo, and other supported video platforms.
Works with any post type, including custom post types.
Provides a user-friendly interface for setting featured videos.