Last active
November 14, 2015 12:49
-
-
Save cezarpopa/f9a4aeceded937945fa1 to your computer and use it in GitHub Desktop.
add url / slug from page/pages to body WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Adds custom classes to the array of body classes. | |
| * Based @Underscores.me | |
| * @param array $classes Classes for the body element. | |
| * @return array | |
| */ | |
| function ks_body_classes( $classes ) { | |
| // Adds a class of group-blog to blogs with more than 1 published author. | |
| if ( is_multi_author() ) { | |
| $classes[] = 'group-blog'; | |
| } | |
| global $wp_query; | |
| $page = ''; | |
| if (is_front_page() ) { | |
| $page = 'home'; | |
| } elseif (is_page()) { | |
| $page = $wp_query->query_vars["pagename"]; | |
| } | |
| if ($page) | |
| echo 'class= "'. $page . '"'; | |
| // Adds a class of hfeed to non-singular pages. | |
| if ( ! is_singular() ) { | |
| $classes[] = 'hfeed'; | |
| } | |
| return $classes; | |
| } | |
| add_filter( 'body_class', 'ks_body_classes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment