admin管理员组

文章数量:1334887

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?

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?

Share Improve this question asked Jun 2, 2020 at 14:30 ralphjsmitralphjsmit 4026 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

$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

本文标签: variablesWhat is the use of contentwidth