Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.