WordPress.org

Support

Support » Themes and Templates » $content_width ??

$content_width ??

  • I am looking at the Able theme on wp.com and d/led the source code for the theme from https://wpcom-themes.svn.automattic.com/. in this theme, the $content_width is set to 1176 if there are no sidebars, 869 if there is one sidebar, and to 562 if there are 2 sidebars and the width of the content does seem to match the value in $content_width depending on the presence of sidebars or not.

    how does wordpress make the connection between this value and the width of the content area? I just don’t see where and how it is connected.

    Al

Viewing 7 replies - 1 through 7 (of 7 total)
  • $content_width isn’t the width of the content area — it’s a constant used to set the maximum width of embedded content like videos. It’s a standard part of just about any well-coded theme.

    The width of the content area itself is generally set in style.css

    but, as I said above, this theme sets the width of the content area ($content_width) depending on 0, 1, or 2 sidebars and seems to use the values set by the specification of $content_width in functions.php (1176, 869, or 562). because it is varaible depending on the # of sidebars, it cannot be set in css or so it would appear to me.

    so that is why I am asking the question? how does this work? just trying to figure out how it works so that if I want to use it, I can understand it. right now I don’t understand how the page shows full page width if there are no sidebars, displays 3/4 page if there is one sidebar, and half the page if there are 2 sidebars. it is a neat process that may be usable if I can figure out how it works.

    Al

    Ah, I got distracted by $content_width and misunderstood your real question, in that case!

    Take a look at the able/inc/tweaks.php file — there’s a function in there that adds extra css classes (.one-column, .two-column, .three-column) to the body depending on which sidebars are present; those classes are styled in the page structure section of style.css

    OK that may explain it, will look at that. so in the end, it is done only with CSS, and the fact that content_width is set to some values that seem to relate to the content width size only throws you off, especially when they used a name like content_width.

    thanks Amy

    Thanksgiving Day here in Canada (we celebrate in October)

    Al

    Yeah, content_width is… accurate in that it’s the width of some content, it’s just not the kind that seems most obvious 😉 You’re not the first person to stumble on that, or even close to it.

    Happy Thanksgiving!

    Hi… I interested to build a WordPress Theme. I follow the instruction to build the themes on wordpress.or.id. But, when i check my theme, there are some problems, and one of the problems are :

    REQUIRED: No content width has been defined. Example:

    if ( ! isset( $content_width ) ) $content_width = 900;

    So, where i must add the $content_width ?

    I’m still newbie here…
    Thanks for helps…

    Ahaaa…. I’ve figured out now. I just see the example from twentytwelve theme, and read from codex.wordpress.org/Content_Width

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘$content_width ??’ is closed to new replies.
Skip to toolbar