Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. // Title: Add the slug inside the WordPress page main body tag class
  2. // Description: This function will include the slug
  3. // of every page created inside the class section of the body class.
  4. function slug_body_class_for_pages( $classes ) {
  5. if ( is_singular( 'page' ) ) {
  6. global $post;
  7. $classes[] = 'page-' . $post->post_name;
  8. }
  9. return $classes;
  10. }
  11. add_filter( 'body_class', 'slug_body_class_for_pages' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement