how to create a conditional content_width for a wordpress theme?

No, its not possible. $content_width is a theme-wide constant, and its set in functions.php before any of the query conditionals are set.

$content_width is used to determine the intermediate image sizes in image_send_to_editor. The “large” image size will be set to the value of $content_width.

If you need to modify those sizes on a per-category basis, you can hook into that filter… see my answer on the question change set_post_thumbnail_size according to post type admin page for a general example of how this can be done (note that this will almost always fail if you’re trying to do it by category, as the post category is almost always not set when the user first uploads an image – setting it by post type is a little more reliable)

No matter how wide your posts and pages are, set $content_width to the widest image you want a user to include in a post.

Leave a Comment