Problem inserting youtube code into posts
-
I have a wordpress site met Woocommerce. If a product on my shop has a productvideo, I include it into the description via a bit of code:
(example)
<div class="codegena" style="position:relative;width:100%;height:0;padding-bottom:56.27198%;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" width='560' height='315' src="https://www.youtube.com/embed/5yscgPlzaqM?&theme=dark&autohide=1&modestbranding=1&rel=0&iv_load_policy=3"frameborder="0"></iframe></div>
This bit of code gives me the design and look that perfectly matches how I want to show it.Annoyingly, this code gets deleted at random moments, and changes into:
<div class="codegena" style="width:100%;height:0;padding-bottom:56.27198%"></div>
I honestly don’t understand why WordPress thinks its needed to edit my code, but the only thing I managed to find is:
// this function initializes the iframe elements function add_iframe($initArray) { $initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"; return $initArray; } // this function alters the way the WordPress editor filters your code add_filter('tiny_mce_before_init', 'add_iframe');
However, this doesn’t really work. Once a week I need to check my product 1 by 1 to see if the video is still showing.
Is there a working code that tells wordpress to leave my code alone. I seriously dislike having to check 250 products 1 by 1 every week! And I genuinely don’t understand why WordPress actually edits my code at all…
- The topic ‘Problem inserting youtube code into posts’ is closed to new replies.