This post provides an overview of the various ways to submit and display video files.

If you’re new to WordPress and/or USP Pro, you may feel overwhelmed by the different ways to do things. For example, there are numerous ways to upload and display video. Here is a quick overview to get you started:

Adding video using WP’s oEmbed method

  • Include the [usp_content] shortcode in the form
  • Instruct the user to add each URL on its own line
  • The video URL will appear in the post content area
  • The video will be displayed on the front-end automatically

Adding video by direct file upload

  • Include the [usp_files] shortcode in the form
  • The user selects the file(s) from his/her local machine
  • The files are uploaded to the Media Library
  • The URLs for the files are attached to submitted posts as custom fields
  • Use a shortcode or template tag to display videos on front-end

Adding images and other file types

  • Include the [usp_files] shortcode in the form
  • The user selects the file(s) from his/her local machine
  • The files are uploaded to the Media Library
  • The URLs for the files are attached as custom fields
  • Use a shortcode or template tag to display on front-end

Display video on the front-end

The easiest way to display custom fields like images and video is to use the free Helper plugin. Simply activate, enter the name(s) of your custom field(s), save changes and done. Check that linked tutorial for complete information.

Display video with oEmbed

Going the oEmbed route for video files, you can either display them automatically by including the video URL on its own line in the post content; or, you can display video files that are attached to posts as custom fields. Here is a quick example showing how to do so:

<?php // display video via oEmbed

$video_url = usp_get_meta(false, 'video-1');
$video = wp_oembed_get($video_url);

if (!empty($video)) {
    echo $video;
} else {
    // do something if no video URL is found
} ?>

If you add that to your theme template (e.g., single.php), it will display the video that’s specified in the custom field named video-1. Change that to the name of the custom field that contains the video URL.

For example, in my USP Form, say I have include this shortcode:

[usp_custom_field form="video-1" id="1"]

After the user adds a video URL and submits the form, the video URL will be attached to the submitted post as a custom field. We can now add the code above in single.php, archive.php, and any other template that should display videos.

This technique could be repeated to display as many videos as required.

Related Resources