WordPress 3.x will automatically remove iFrame tags when you switch between HTML and Visual mode.
In order to prevent that issue, simply install TSL iframe unfilter plugin.This will fix the issue of Youtube iframe embedded code disappearing or any other iframe code you’ve got.
To automatically center Youtube videos using the iframe embedded code (supporting for flash and HTML5), edit style.css in Appearance->Editor, and add the lines
/* Align iFrame Youtube Videos */
.youtube-player { display: block; margin: 0 auto; }
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
Youtube apparently removed class=”youtube-player” in the iFrame code. If you want the CSS code above to work (to center youtube videos), simply add back class=”youtube-player”.
Better solution at http://wordpress.org/support/topic/how-to-center-youtube-video?replies=10#post-4600728
Add the following in stylesheet.css of your theme
.post_content iframe {
margin: 0 auto;
}
It does not require TSL filter plugin.