Skip to content

Instantly share code, notes, and snippets.

@andreiglingeanu
Last active December 13, 2023 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreiglingeanu/7f1811aa31136c05c7fc4dcd5892809a to your computer and use it in GitHub Desktop.
Save andreiglingeanu/7f1811aa31136c05c7fc4dcd5892809a to your computer and use it in GitHub Desktop.
<?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