Created
March 30, 2021 16:25
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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