Skip to content

Instantly share code, notes, and snippets.

@marcelotorres
Created November 24, 2016 12:55
Show Gist options
  • Save marcelotorres/0883eae35d042caf16b850d59a47eb39 to your computer and use it in GitHub Desktop.
Save marcelotorres/0883eae35d042caf16b850d59a47eb39 to your computer and use it in GitHub Desktop.
Filter to put more classes in the body class function, in the example below you are adding the "post slug"
<?php
/*
* Filtro para colocar mais classes na função body class, no exmeplo abaixo está adicionando o "slug do post"
*/
add_filter('body_class', 'body_classes_plus');
function body_classes_plus($classes) {
global $post;
$classes[] = (!is_home()) ? $post->post_name : ''; // Slug do post
//$classes[] = 'anything else';
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment