Wordpress - Add Page Name Slug to Body classes


/ Published in: PHP
Save to your folder(s)

Add page name slug to Wordpress body class array.


Copy this code and paste it in your HTML
  1. add_filter('body_class', 'add_browser_classes');
  2. function add_browser_classes($classes){
  3. global $wp_query;
  4. $page = '';
  5. if(is_page()) {
  6. $classes[] = $wp_query->query_vars["pagename"];
  7. }
  8.  
  9. return $classes;
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.