Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Display WooCommerce category image on category archive page.
- */
- function polestar_child_woocommerce_category_image() {
- if ( function_exists( 'is_woocommerce' ) && is_product_category() ) {
- global $wp_query;
- $cat = $wp_query->get_queried_object();
- $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
- $image = wp_get_attachment_url( $thumbnail_id );
- if ( $image ) {
- echo '<div class="polestar-wc-category-banner" style="background: url(' . $image . ') no-repeat; background-size: cover; height: 200px; margin-bottom: 30px; width: 100%;"></div>';
- }
- }
- }
- add_action( 'polestar_content_before', 'polestar_child_woocommerce_category_image', 2 );
- /**
- * Adds child theme custom classes to the array of body classes.
- *
- * @param array $classes Classes for the body element.
- * @return array
- */
- function polestar_child_body_classes( $classes ) {
- // Header margin.
- if ( function_exists( 'is_woocommerce' ) && is_product_category() ) {
- global $wp_query;
- $cat = $wp_query->get_queried_object();
- $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
- $image = wp_get_attachment_url( $thumbnail_id );
- if ( $image ) {
- $classes[] = 'no-header-margin';
- }
- return $classes;
- }
- }
- add_filter( 'body_class', 'polestar_child_body_classes' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement