Created
April 14, 2013 18:08
-
-
Save intelliweb/5383629 to your computer and use it in GitHub Desktop.
WP: dynamically add CSS class to body tag based on website domain. Useful when your using the same theme on all sites, but want to alter some styling (e.g. background) on some sites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add custom CSS class to <body> tag | |
add_filter('body_class','intw_body_class'); | |
function intw_body_class($classes) { | |
$url = get_bloginfo('url'); | |
if( ($url == 'http://siteA.com') || ($url == 'http://devserver.com/siteA') ) { | |
$classes[] = 'siteA'; | |
return $classes; | |
} elseif ( ($url == 'http://siteB.com') || ($url == 'http://devserver.com/siteB') ) { | |
$classes[] = 'siteB'; | |
return $classes; | |
} elseif ( ($url == 'http://siteC.com') || ($url == 'http://devserver.com/siteC') ) { | |
$classes[] = 'siteC'; | |
return $classes; | |
} elseif ( ($url == 'http://siteD.com') || ($url == 'http://devserver.com/siteD') ) { | |
$classes[] = 'siteD'; | |
return $classes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment