Last active
December 13, 2023 07:59
-
-
Save andreiglingeanu/7f1811aa31136c05c7fc4dcd5892809a to your computer and use it in GitHub Desktop.
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
<?php | |
add_action('wp_head', function () { | |
$term_id = get_queried_object_id(); | |
if (! is_woocommerce() || ! $term_id || is_product()) { | |
return; | |
} | |
$attachment_id = get_term_meta($term_id, 'thumbnail_id'); | |
if ($attachment_id && ! empty($attachment_id)) { | |
$attachment_id = $attachment_id[0]; | |
} | |
$css = ''; | |
if ($attachment_id) { | |
// Has image | |
$css .= 'header.entry-header.ct-container nav, header.entry-header.ct-container .ct-home-icon { color: #fff; }'; | |
} else { | |
// No image | |
$css .= 'header.entry-header.ct-container { min-height: 120px; }'; | |
$css .= 'header.entry-header.ct-container h3, header.entry-header.ct-container nav { color: black; }'; | |
// More styles that you might need... | |
} | |
echo '<style>' . $css . '</style>'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment