Skip to content

Instantly share code, notes, and snippets.

@frankyonnetti
Last active May 23, 2021 21:18
Show Gist options
  • Select an option

  • Save frankyonnetti/833668de996000f8e6a7e03a9bcf2830 to your computer and use it in GitHub Desktop.

Select an option

Save frankyonnetti/833668de996000f8e6a7e03a9bcf2830 to your computer and use it in GitHub Desktop.
Wordpress - Page Slug Body Class #wordpress #class
<?php
/**
* Page Slug Body Class
*/
function add_slug_body_class( $classes ) {
global $post;
if (isset($post)) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment