One of the most annoying habits of WordPress is that when you add a twitter link it will generate the oEmbed for you automatically but there is no way of centering it. This is because the centering is set at the embed level and by default WordPress has it set to load it to the left hand side.

There are a couple of ways that this can be done but instead of going through the many complicated ways there is actually a very quick and simple fix that doesn’t require the use of a plugin and can be done with only CSS.

If you are using a child theme or the Custom CSS module in the customizer all you need to do is add the following CSS to it and the oEmbeds will automatically align to the center of the page. Many themes will also have a custom CSS section (in the theme options) and you can paste this code into there as well so long as it applies to the front-end of the site it will work.

.twitter-tweet {margin: auto;}

After the CSS has been added you should notice that all of the previous posts will now also be centered. Its important to note that you will need to clear your caching plugin. In addition in the edit window your Tweet might not appear to have been centered but in the published post you should see proper alignment. The best part is this should work on any site / theme so long as the embeds are being processed through the WordPress oEmbed system.

Now save yourself a plugin, fix the annoying twitter embeds and make your site both faster but more accessible for your users! Remember, always save yourself the pain of messing with PHP if you aren’t a developer.


Please enter your comment!
Please enter your name here