[theme-reviewers] $content_width and after_theme_setup: d'oh!

Otto otto at ottodestruct.com
Sun Jan 16 01:04:38 UTC 2011


Actually, I believe it only needs to be set globally. The easy way to
do this is to set it outside that hook, and that's what twentyten
does, but this would be equally valid:

add_action('after_theme_setup','theme_setup');
function theme_setup() {
  global $content_width;
  if ( ! isset( $content_width ) )
    $content_width=640;
}

Also equally valid would be to set $_GLOBALS['content_width'] = 640;
or similar. Same thing, really.

However, for theme compatibility (and to allow child themes to
override it) the "if ( ! isset( $content_width ) )" should be used as
well.

-Otto


On Sat, Jan 15, 2011 at 7:54 PM, Chip Bennett <chip at chipbennett.net> wrote:
> So, I just realized something today regarding setting $content_width: it
> must be set *before* the after_theme_setup hook.
> Just a mental note to myself, to check functions.php to ensure that the call
> to set $content_width isn't inside of a theme setup function that gets
> called on after_theme_setup. I thought I'd share that with everyone, just in
> case I'm not the only one who needed that clarification. :)
> Chip
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>


More information about the theme-reviewers mailing list