Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tristanmason/03b63626497475278e1e8d238f35e780 to your computer and use it in GitHub Desktop.
Save tristanmason/03b63626497475278e1e8d238f35e780 to your computer and use it in GitHub Desktop.
Check for Astra Advanced Headers and add header ID class to Wordpress body classes for per-header styling
/**
* Check for Astra Advanced Headers and add header ID class to body classes for per-header styling
* @author Tristan Mason <tristanmason.com>
*/
function tmac_add_advanced_header_class( $classes ) {
// only run if Advanced Headers exists and is enabled on this page
if ( (int)method_exists('Astra_Ext_Advanced_Headers_Data', 'get_current_page_header_ids') && in_array('ast-advanced-headers',$classes) ) {
$tmac_header_ids = Astra_Ext_Advanced_Headers_Data::get_current_page_header_ids();
$classes[] = 'tmac-header-id-' . $tmac_header_ids;
}
return $classes;
}
add_action( 'body_class', 'tmac_add_advanced_header_class', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment