Last active
January 16, 2016 14:54
-
-
Save katlove/fa0fff9b601bc813c63d to your computer and use it in GitHub Desktop.
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
| <?php | |
| // Add home hero image as a background in head of home template only w/ media query | |
| // Make sure you have a <div class="home-hero-image"> on the front page template | |
| if( function_exists('get_field') ) { | |
| if ( ! function_exists( 'home_hero_image' ) ) : | |
| add_action( 'wp_head', 'home_hero_image', 16 ); | |
| function home_hero_image() | |
| { | |
| if ( 'is_front_page' And (get_field('home_hero_image'))) { | |
| echo | |
| "<style> | |
| @media (min-width: 500px) { | |
| .home-hero-image { | |
| background-image: url('"; | |
| the_field('home_hero_image'); | |
| echo "');} | |
| } | |
| <!--[if lte IE 8]> | |
| .home-hero-image { background-image: url('"; | |
| the_field('home_hero_image'); | |
| echo "'); } | |
| <![endif]--> | |
| </style>"; | |
| } | |
| } | |
| endif; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment