Skip to content

Instantly share code, notes, and snippets.

@walterebert
Created November 10, 2015 10:28
Show Gist options
  • Save walterebert/8a89e06c68b5387b5772 to your computer and use it in GitHub Desktop.
Save walterebert/8a89e06c68b5387b5772 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