-
Thought this might help someone out or could be submitted to the core code.
But rather than having to assign an image to all woocommerce children categories I have added some code to the header.php on line #21 so that if there is no background image set for the current child category it will check the top most parent and use that background image if there is one set.
if(!$page_heading_background_image) {
function get_parent_terms($term) {
if ($term->parent > 0){
$term = get_term_by(“id”, $term->parent, “product_cat”);
return get_parent_terms($term);
}else{
return $term->term_id;
}
}
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$parent_cat_id = get_parent_terms($cat_obj);
$page_heading_background_image = get_woocommerce_term_meta( $parent_cat_id, ‘product_cat_heading_thumbnail_id’, true );
}
Code Suggestion – Category BG Image
This topic is: not a support question