WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand you have to paste the link that you're embedding without any code wrapping around it, but how do I force the embedded content to be centered? Currently, the default is aligning to the left.

I could modify the core file, but it's highly discouraged, so I'm asking to see if there's any hook or filter to get around this.


share|improve this question
up vote 1 down vote accepted

After some Googling, I found a solution that was originally done for a Twitter embed, but I modified it to work with all oEmbed contents. Keep in mind that for this to work on existing posts, you'll need to do an "update" for the oEmbed content to refresh from the cache.

function center_oembed($html, $url, $args) {
    $html = '<p style="text-align: center;">' . $html . '</p>';
    return $html;
share|improve this answer
FWIW it would probably be better to use .alignleft .aligncenter and .alignright to match the caption/image classes, since you'll probably want your objects to display similarly and it should already work in your theme. – jeremyclarke Sep 23 '15 at 18:14

Quick and dirty CSS fix I came up with for Twitter oEmbed (.entry-content is specific to the theme):

.entry-content > iframe {
    margin: 0 auto !important;

Seems to work, YMMV.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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