Question

In the requirements of Envato I saw that they require a $content_width to be set. I searched for it on the internet but can't really understand why?

I don't use it and the theme is responsive.

If I only declare the $content_width and never use it, what value should I give it?

Was it helpful?

Solution

$content_width is used to set the default width of embeds, for situations when an element needed to specify a width. This is how WP knew the width of the main content area.

However, this was back before the push for responsive design, and modern CSS with fluid embeds and responsive breakpoints. So it isn't needed much but it can still result in odd embeds if you set a bad value. Content width sometimes gets used in other edge cases too, but that was the main use case and its reason for being.

So I suggest:

  • Figure out the content width on the most common desktop resolution, and use it to set $content_width in functions.php
  • Then, apply CSS to adjust embeds responsively/fluidly as you would normally do
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top