fahimmurshed

Remove Elementor css from non-Elementor pages

Feb 24th, 2021
822
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×