1

I have a website that uses a "video" custom post type to display self hosted videos in post. I am trying to figure out how to make a download link for each video that uses this "video" custom post type. Right now the video displays using a custom field called "video_url"

How could i output the video url into this Download link

Thanks in advance for the help.

5
  • 1
    Hi Corey, you should be able to just add code like <a href="<?php echo get_post_meta(get_the_ID(), "video_url", true); ?>">Download video</a> to your theme, in the place you want the link output. Do you know how to do that?
    – Tim Malone
    Commented Apr 22, 2016 at 7:24
  • 1
    So i did the following <a href="<?php echo get_post_meta(get_the_ID(), "video_url", true); ?>">Download video </a> This just seems to echo the custom post url and not the direct video link. Iv tried echoing the acf field id and everything but it wont seem to get the direct link to the mp4 Commented Apr 22, 2016 at 22:00
  • 1
    Is the direct MP4 link in that video_url field? Or does the video_url field contain the link to the post?
    – Tim Malone
    Commented Apr 22, 2016 at 22:29
  • 1
    When i echo "video_url" its a link to the post. The "video_url" references a ACF media upload field. So i am uploading a video then trying to echo the direct link to that video. Commented Apr 22, 2016 at 22:33
  • 1
    Right, that was useful information to know, changes the question entirely :) Change the true to false, and just before the semi-colon, add [url] - I think that should do it, but I'm not at my computer at the moment to check. Otherwise, try print_r to see what's available for you in that custom field
    – Tim Malone
    Commented Apr 22, 2016 at 22:45

1 Answer 1

0

First get the ACF plugin output the video file URL properly. The field has to be set to "Text". Once the get_field("video"); displays the video file URL, you can use it in the link href attribute.

$video = get_field( "video_file_url");

<a href="<?php echo $video; ?>"> Download </a>

I hope this helps.

1
  • Don't forget to sanitize (esc_url()) Commented Nov 5, 2016 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.