From 311447ce7a005a13ca325d2942100ea1c5b0a357 Mon Sep 17 00:00:00 2001 From: mariyan96 Date: Tue, 6 Aug 2019 14:59:59 +0300 Subject: [PATCH] Current page slug is added to the body tag classes like in the template: {"post_type"-"post_name"} --- functions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/functions.php b/functions.php index 324bcb5..8ad0c6d 100644 --- a/functions.php +++ b/functions.php @@ -190,3 +190,14 @@ function dxstarter_remove_html_margin() { remove_action( 'wp_head', '_admin_bar_bump_cb' ); } add_action( 'get_header', 'dxstarter_remove_html_margin' ); + +//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' ); + \ No newline at end of file