$content_width in “twentyfifteen.1.4” WP Default tHEME

$content_width is one of the dark magic global variables wordpress uses. The value refers to the width in pixels of the area in which the post content is being displayed in a post page. It is expected to be set by themes.

The reason for the

if ( ! isset( $content_width ) ) {

is to let child themes to override this value by defining it in their functions.php file

Why is it needed? There might be other needs, but one place in which it is needed is where the oEmbed protocol is being used to retrieve some HTML (usually an iframe) from a 3rd party service. For example a youtube video sharing iframe that is retrieved based on a youtube URL.

As part of the oEmbed protocol you can let the 3rd party server know the dimensions of area it may fill, and wordpress core needs to assume something that will make some sense just based on the youtube url, and it will use the single post content width – the $content_width variable.

Looking now at the 4.4 code I see that there are more uses, the native video shortcode, getting images in the correct size for the editor and more.

BTW the default is 500

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş