Skip to content

Instantly share code, notes, and snippets.

@cdils
Forked from norcross/string-body-class.php
Last active January 4, 2016 00:09
Show Gist options
  • Save cdils/8539634 to your computer and use it in GitHub Desktop.
Save cdils/8539634 to your computer and use it in GitHub Desktop.
Strip "color" id/value from querystring and use as body class. Prepends "theme-prefix-" to the color name. Example: For http://www.example.com/?color=blue the class would be "theme-prefix-blue."
<?php //remove opening tag
add_filter('body_class', 'string_body_class');
function string_body_class( $classes ) {
if ( isset( $_GET['color'] ) ) :
$classes[] = 'theme-prefix-' . sanitize_html_class( $_GET['color'] );
endif;
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment