Skip to content

Instantly share code, notes, and snippets.

@diggeddy
Created January 30, 2023 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diggeddy/3ed2334b55f67f64f7d2274744f1deac to your computer and use it in GitHub Desktop.
Save diggeddy/3ed2334b55f67f64f7d2274744f1deac to your computer and use it in GitHub Desktop.
Add GeneratePress Element Class to body tag
<?php
add_filter( 'body_class', function( $classes ) {
global $generate_elements;
foreach ( $generate_elements as $element => $data ) {
$element_title = 'gp-elem-' . strtolower(str_replace(' ', '-', get_the_title( $data['id'] ) ));
$classes[] = $element_title;
}
return $classes;
});
@diggeddy
Copy link
Author

In GeneratePress premium, add a class to the body tag for each element on page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment