PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] How to upload a video using ACF in WordPress?

 May 15, 2022     advanced-custom-fields, php, wordpress     No comments   

Issue

I am still at learning phase in WordPress. I cannot figure out in ACF which field type should I choose to upload a video file and which code should I write to show it at the front-end. Please look into the below code. I am using the_field('') but it isn't working. Can anyone help

                <video width="954" height="535" controls class="tm-mb-40">

                    <source src="video/wheat-field.mp4" type="video/mp4">   
                      
                    Your browser does not support the video tag.

                </video>

Solution

You can use ACF Type Link in the backend to attach video link like these

    <?php 
    
    $link_data = get_field('video_link'); 
    
    if(!empty($link_data))
    { 
    $link = $link_data['url'];  
    
    ?>
    
    <video width="954" height="535" controls class="tm-mb-40">
      
        <source src="<?php echo $link; ?>" type="video/mp4">   
                          
        Your browser does not support the video tag.
    
    </video>

<?php } ?>


Answered By - Sanket Thakkar
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing