Advertisement
tex2005

Remove Elementor css from non-Elementor pages

Dec 3rd, 2020
3,544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. /**
  2.  * Remove Elementor css from non-Elementor pages
  3.  */
  4. add_filter( 'body_class', 'custom_body_classes', 90,1);
  5. function custom_body_classes( $classes ){
  6.  
  7.     # get template filename
  8.     $template_url = get_page_template();
  9.     $template_url_array = explode('/',$template_url);
  10.     $template_file = end($template_url_array);
  11.  
  12.     # Elementor is using my page.php tempalte file, which I'm never using for non-Elementor pages
  13.     if( $template_file != "page.php" ) { // if NOT elementor
  14.  
  15.         foreach ($classes as $classname) {
  16.             if ($classname != "elementor-kit-695"){ // Elementor adds this class to all, verify the "695" number!
  17.                 $classes_2[] = $classname; // build new array that excludes Elementor's class
  18.             }
  19.         }
  20.         return $classes_2;
  21.     }
  22.  
  23.   return $classes;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement