Last active
February 19, 2020 10:16
-
-
Save diggeddy/6478d0b724bf6c5d680e9f0dd25e720c to your computer and use it in GitHub Desktop.
Use woo thumbnail for Header Element Background
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
add_filter( 'generate_page_hero_background_image_url', function( $url ) { | |
if ( ! function_exists( 'get_woocommerce_term_meta' ) ) { | |
return $url; | |
} | |
global $wp_query; | |
$cat = $wp_query->get_queried_object(); | |
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); | |
$background_image = wp_get_attachment_url( $thumbnail_id ); | |
if ( $background_image ) { | |
$url = $background_image; | |
} | |
return $url; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment