Skip to content

Instantly share code, notes, and snippets.

@diggeddy
Last active February 19, 2020 10:16
Show Gist options
  • Save diggeddy/6478d0b724bf6c5d680e9f0dd25e720c to your computer and use it in GitHub Desktop.
Save diggeddy/6478d0b724bf6c5d680e9f0dd25e720c to your computer and use it in GitHub Desktop.
Use woo thumbnail for Header Element Background
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