Last active
December 13, 2015 11:44
-
-
Save hampusn/e1befdfbff3108f9df4b to your computer and use it in GitHub Desktop.
FB: ACF field to body_class() via filter
This file contains 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
<?php | |
/** | |
* WP Filter which adds acf field value to body classes for all pages but home. | |
* | |
* @see https://codex.wordpress.org/Plugin_API/Filter_Reference/body_class | |
*/ | |
function THEME_NAME_body_class( $classes ) { | |
if ( function_exists( 'get_field' ) && ! is_home() ) { | |
$classes[] = get_field( 'page_background' ); | |
} | |
return $classes; | |
} | |
add_filter( 'body_class', 'THEME_NAME_body_class' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment