Title: HTML5 Video in WordPress
Last modified: August 22, 2016

---

# HTML5 Video in WordPress

 *  [abtx](https://wordpress.org/support/users/abtx/)
 * (@abtx)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/)
 *     ```
       <video width="100%" height="100%">
       <source src="<?php echo $video_mp4; ?>" type="video/mp4">
       </video>
       ```
   
 * Hi,
    Above code outputs url as html value instead of rendering actual media file.
   $video is media file url fetched from custom field. it’s a correct url leading
   to the file and the file plays in the browser. Why is WordPress ignoring video
   tags?
 * Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/#post-5391864)
 * Where are you placing this code? You can’t put PHP in post content if that’s 
   where it is. Have you checked the actual HTML output to your browser? If that
   HTML is correct, it’s not WP doing something wrong. If it is incorrect, how it
   is incorrect would be a clue to how to fix it.
 *  Thread Starter [abtx](https://wordpress.org/support/users/abtx/)
 * (@abtx)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/#post-5391866)
 * it’s in the loop, see below. it’s the correct link to media file, web inspector
   shows no video tags or source tags, just the plain html url.
 *     ```
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
       <div class="slide" data-content="<?php echo get_the_title(); ?>" data-hash="<?php echo get_permalink($post->ID);?>">
   
           <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID ), 'post'); ?>
   
           <div class="img-wrap" style="background-image:url('<?php echo $thumb[0]; ?>')"></div>
   
           <h2>
               <?php echo get_the_title(); ?>
               <span><?php echo get_the_content(); ?></span>
           </h2>
   
           <?php $video_mp4= the_field( 'background_video_mp4'); $video_ogg = the_field( 'background_video_ogg');?>
   
           <video width="100%" height="100%">
       		 	<source src="<?php echo $video_mp4; ?>" type="video/mp4">
       		  <source src="<?php echo $video_ogg; ?>" type="video/ogg">
       		</video>
   
       </div>
       <?php endwhile; endif; ?>
       ```
   
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/#post-5391919)
 * Thanks for the extra info, that really helped me understand the issue.
 * That is really weird! I can’t even imagine how video tags would be filtered out,
   that’s not how PHP works. When HTML is encountered when processing a file, it
   is immediately sent out to the user’s browser. AFAIK there is no way for anything
   in WP to impact this process in any way.
 * I placed your code in one of my templates and everything was output as expected.
   The only explanation I can think of is your template isn’t even being loaded,
   the video URLs are picked up in some way by some other code and output without
   the video tags. It’s a rather far fetched theory, I know. You can prove it one
   way or another by placing something like `<!-- This is my template's output --
   >` in your code. Whether it appears or not in the output will indicate whether
   your code is even being executed.
 *  Thread Starter [abtx](https://wordpress.org/support/users/abtx/)
 * (@abtx)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/#post-5391920)
 * Hi,
 * funny enough, this is the template. I’ve developed the theme from scratch, on
   the second though, I wonder whether I need to register support for HTML5 video
   in functions.php, but I doubt it. As you say, the html should be rendered just
   fine, the php should echo the url in src attribute. This is against common sense.
   There is no explanation why this particular part of html is being ignored other
   than WordPress seeing it as some illegal, not registered operation, I think.
 *  Thread Starter [abtx](https://wordpress.org/support/users/abtx/)
 * (@abtx)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/#post-5391921)
 * ok, I got it. it was this part `<?php $video_mp4= the_field( 'background_video_mp4');
   $video_ogg = the_field( 'background_video_ogg');?>` that outputs url, no need
   for echo. placing this directly in src attribute renders the video. As most cases,
   it was a prosaic cause.
 * Cheers

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘HTML5 Video in WordPress’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [html5](https://wordpress.org/support/topic-tag/html5/)
 * [video](https://wordpress.org/support/topic-tag/video/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 5 replies
 * 2 participants
 * Last reply from: [abtx](https://wordpress.org/support/users/abtx/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/html5-video-in-wordpress/#post-5391921)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
