mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
17 lines
480 B
Text
17 lines
480 B
Text
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;
|
|
});
|