Created
August 4, 2017 00:23
-
-
Save seothemes/35cb295a4aa3c1f8232257d4a219ff09 to your computer and use it in GitHub Desktop.
Studio Pro v2.0.2 custom header fix.
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 // DO NOT INCLUDE THIS LINE | |
/** | |
* Custom header image callback. | |
* | |
* Loads image or video depending on what is set. | |
* If a featured image is set it will override the | |
* header image. If a video is set it will be used | |
* on the home page only. | |
* | |
* @since 1.5.0 | |
*/ | |
function studio_custom_header() { | |
// Get the featured image if one is set. | |
if ( get_the_post_thumbnail_url() ) { | |
$image = ''; | |
if ( class_exists( 'WooCommerce' ) && is_shop() ) { | |
$image = get_the_post_thumbnail_url( get_option( 'woocommerce_shop_page_id' ) ); | |
if ( ! $image ) { | |
$image = get_header_image(); | |
} | |
} elseif ( is_front_page() && is_active_sidebar( 'front-page-1' ) ) { | |
$image = ''; | |
} elseif ( is_home() ) { | |
$image = get_the_post_thumbnail_url( get_option( 'page_for_posts' ) ); | |
if ( ! $image ) { | |
$image = get_header_image(); | |
} | |
} elseif ( is_archive() || is_category() || is_tag() || is_tax() || is_home() ) { | |
$image = get_header_image(); | |
} else { | |
$image = get_the_post_thumbnail_url(); | |
} | |
} elseif ( has_header_image() ) { | |
$image = get_header_image(); | |
} | |
if ( ! empty( $image ) ) { | |
printf( '<style>.hero-section,.before-footer{ background-image:url(%s);}</style>', esc_url( $image ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment