Home / Archive / Add the page slug body class
Duplicate Snippet

Embed Snippet on Your Site

Add the page slug body class

snippet add slug

Code Preview
php
<?php
function wpcode_snippet_add_slug_body_class( $classes ) {
	global $post;
	if ( isset( $post ) ) {
		$classes[] = $post->post_type . '-' . $post->post_name;
	}
	return $classes;
}
add_filter( 'body_class', 'wpcode_snippet_add_slug_body_class' );

Comments

Add a Comment