Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created March 3, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/9326821 to your computer and use it in GitHub Desktop.
Save billerickson/9326821 to your computer and use it in GitHub Desktop.
<?php
/**
* Add Site Name as Body Class
*
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-class-body-tag/
*
* @param array $classes
* @return array
*/
function be_site_name_in_body( $classes ) {
$class = str_replace( array( 'http://', 'www.', '.', '/' ), array( '', '', '-', '-' ), home_url() );
$classes[] = sanitize_html_class( $class );
return $classes;
}
add_action( 'body_class', 'be_site_name_in_body' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment