Skip to content

Instantly share code, notes, and snippets.

@Zodiac1978
Last active March 16, 2022 09:57
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 Zodiac1978/9b7571d999e6d1df33b8b8891410ec0f to your computer and use it in GitHub Desktop.
Save Zodiac1978/9b7571d999e6d1df33b8b8891410ec0f to your computer and use it in GitHub Desktop.
Add body class if title is hidden in GeneratePress (https://generatepress.com/)
<?php
/**
* Add body class if title is hidden.
*
* @param array $classes An array of body class names.
* @return array An array of body class names with added class name if title is hidden.
*/
function add_body_class_if_title_hidden( $classes ) {
if ( ! generate_show_title() ) {
$classes[] = 'gp-title-hidden';
}
return $classes;
}
add_filter( 'body_class', 'add_body_class_if_title_hidden' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment