Skip to content

Instantly share code, notes, and snippets.

@hampusn
Last active December 13, 2015 11:44
Show Gist options
  • Save hampusn/e1befdfbff3108f9df4b to your computer and use it in GitHub Desktop.
Save hampusn/e1befdfbff3108f9df4b to your computer and use it in GitHub Desktop.
FB: ACF field to body_class() via filter
<?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