Make WordPress Twitter Embeds Responsive

By default WordPress twitter embedded tweets have a fixed width of 550px which is added to the inline style with an !important declaration to stop you overriding it. This breaks responsive layouts and causes horizontal scrolling as soon as your site is viewed at less than 550px wide.

Add the following to your themes functions.php file:

function twitter_no_width($html, $url, $args) {
	if (false !== strpos($url, '')) {
		$html = str_replace('width="550"','',$html);
	return $html;

This removes the hardcoded 550px width from the generated output. If you’ve got existing embedded tweets you’ll need to re-save the posts to regenerate the embed code.

Thanks to Otto for the tip.

6 thoughts on “Make WordPress Twitter Embeds Responsive

  1. function didn’t work for me, but Jasdeep’s CSS code did a good job 🙂 Thanks for sharing

Comments are closed.