Skip to content

Instantly share code, notes, and snippets.

@Sstobo
Last active November 17, 2017 14:27
Show Gist options
  • Save Sstobo/b69f56d00b6235e5f8b96fc9fc8ff2cb to your computer and use it in GitHub Desktop.
Save Sstobo/b69f56d00b6235e5f8b96fc9fc8ff2cb to your computer and use it in GitHub Desktop.
[extras.php dynamic css generation] #php #fp
function inhab_dynamic_css() {
if ( ! is_page_template( 'about.php')) {
return;
}
$image = CFS()->get('about_header_image') ;
if (! $image) {
return;
}
$hero_css = ".page-template-about .entry-header {
background:
linear-gradient( to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.4) 100% ),
url({$image}) no-repeat center bottom;
background-size: cover, cover;
}";
wp_add_inline_style( 'tent-style', $hero_css );
}
add_action( 'wp_enqueue_scripts', 'inhab_dynamic_css' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment