Skip to content

Instantly share code, notes, and snippets.

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 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'] );
return $classes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment