Skip to content

Instantly share code, notes, and snippets.

@itsdavidmorgan
Created May 8, 2013 04:56
Show Gist options
  • Save itsdavidmorgan/5538285 to your computer and use it in GitHub Desktop.
Save itsdavidmorgan/5538285 to your computer and use it in GitHub Desktop.
Content width with active sidebars
function photographer_content_width() {
if ( ! is_single() || is_active_sidebar( 'post-sidebar' ) ) {
global $content_width;
$content_width = 900;
}
if ( ! is_home() || is_archive() || is_active_sidebar( 'blog-sidebar' ) ) {
global $content_width;
$content_width = 900;
}
if ( ! is_page() || is_active_sidebar( 'page-sidebar' ) ) {
global $content_width;
$content_width = 900;
}
if ( ! is_front_page() || is_page_template('template-home.php') || is_active_sidebar( 'home-sidebar' ) ) {
global $content_width;
$content_width = 900;
}
}
add_action( 'template_redirect', 'photographer_content_width' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment