Skip to content

Instantly share code, notes, and snippets.

@pascalmaddin
Forked from walterebert/functions.php
Created November 20, 2015 13:19
Show Gist options
  • Save pascalmaddin/71f19c5d5fbaa1e53046 to your computer and use it in GitHub Desktop.
Save pascalmaddin/71f19c5d5fbaa1e53046 to your computer and use it in GitHub Desktop.
WordPress snippet: Add mobile CSS class
<?php
function my_body_class( $classes ) {
if ( wp_is_mobile() ) {
$classes[] = 'is-mobile';
}
return $classes;
}
add_filter( 'body_class', 'my_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment