WordPress has a neat built-in feature that, when composing a post, if you put the URL to a specific tweet on its own line, like this…
…then WordPress will automatically convert it to a tweet link, like this:
Current forecast for the Portland area: Sunday night we may see a foot of snow…or perhaps just a cold rain.
I love weather forecasts.
— Rob Griffiths (@rgriff) February 4, 2017
By default, though, the embedded tweets will be left-aligned. I wanted them center aligned, as above. And because I just wasted 15 minutes figuring this out, I'm documenting the solution here to save myself future aggravations…
I thought a center align would be as simple as wrapping the tweet URL line in a center-aligned div, but that doesn't work. So I searched the web and found pages of results. After trying and failing with many of those solutions, I finally got smart and looked at the source code…should've done that first.
Embedded tweets—at least as of 4.7.2—are assigned to a class named twitter-tweet. So to center all embedded tweets, you just need to add a simple class definition to your theme's CSS:
/* Center the damn tweets */
margin: 0 auto !important;
Note: The aggravated tone in the style comment is completely optional.