Archived topic
Custom Hero Image woocommerce
1 reply · Started by angela on January 27, 2020
Viewing posts 1–2 of 2
I started with the Mellow from your site library.
I have woocommerce and the page hero wants to pull the featured image from woocommerce which is like the first product image. Obviously a hero and a first product image are completely different.
So is there a way I can add a URL to a custom field and have that shown as the hero image?
Hi there,
You can definitely use a custom field.
For example:
add_filter( 'generate_page_hero_background_image_url', function( $url, $options ) {
if ( is_singular( 'product' ) ) {
$custom_field = get_post_meta( get_the_ID(), 'your_custom_field', true );
if ( $custom_field ) {
$url = $custom_field;
}
}
return $url;
}, 10, 2 );
Let me know if you need more info :)
This archived topic is closed to new replies.