Skip to content

Commit

Permalink
#308 Add page slug to body tag classes
Browse files Browse the repository at this point in the history
  • Loading branch information
roytfrank committed Jul 17, 2023
1 parent e9e02b8 commit 7ef179b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,21 @@ function responsive_branding_copyright() {

add_action( 'r_after_footer_menus', 'responsive_branding_copyright' );

/**
* Add slug of page as a class to body tag
*/
function r_add_page_slug_to_body_tag_classes( $classes ) {
$post = get_post();
$classes_type = is_array( $classes ) ? true : false;

if ( $post && $classes_type && ! in_array( $post->post_name, $classes, true ) ) {
array_push( $classes, $post->post_name );
}

return $classes;
}
add_filter( 'body_class', 'r_add_page_slug_to_body_tag_classes' );

// add_filter( 'theme_page_templates', 'r_remove_news_template', 10, 3 );
/**
* Admin.
Expand Down

0 comments on commit 7ef179b

Please sign in to comment.