How to display brand’s description in sidebar

This topic has 6 replies, 2 voices, and was last updated 3 years ago ago by Olga Barlow

  • Avatar: andrey-4923
    Andrey
    Participant
    November 22, 2021 at 19:53

    Hey,
    How to display brand’s description (html) in sidebar on product page? By default only logo is displayed.
    Royal Theme

    5 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    November 24, 2021 at 12:48

    Hello,

    Provide us with WP Dashboard and FTP access. We’ll help you with this. There is no option to enable that, so minor customization is required.

    Regards

    Avatar: andrey-4923
    Andrey
    Participant
    November 25, 2021 at 11:32

    Hello,
    Thank you for your offer to help, but unfortunately I can’t give access to anyone.
    Could you tell me please any tips what file to find and what text to add?
    p.s.
    Good advice to add this option to your theme 😉

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    November 25, 2021 at 12:03

    Hello,

    1) Add the below code to child theme functions.php

    add_shortcode('product_brand_single', 'et_product_brand_single');
    function et_product_brand_single() {
    	global $post, $wpdb, $product;
        $terms = wp_get_post_terms( $post->ID, 'brand' );   
        if(count($terms)>0) {
        	?>
    		<div class="product-brands">
    			<h4 class="widget-title"><span><?php esc_html_e('Product brand', 'royal-core') ?></span></h4>
            	<?php
    		        foreach($terms as $brand) {
    		            $image 			= '';
    		        	$thumbnail_id 	= absint( get_term_meta( $brand->term_id, 'thumbnail_id', true ) );
    		        	?>
                    	<a href="<?php echo get_term_link($brand); ?>">
    			        	<?php
    			        	if ($thumbnail_id) :
    			        		$image = etheme_get_image( $thumbnail_id );
    			                ?>
    			                		<?php if($image != ''): ?>
    			                    		<img src="<?php echo $image; ?>" title="<?php echo $brand->name; ?>" alt="<?php echo $brand->name; ?>" class="brand-image" />
    			                    	<?php else: ?>
    			                    		<?php echo $brand->name; ?>			                    		
    			                    	<?php endif; ?>
    			                <?php
    			            else :
    			            	echo $brand->name;
    			        	endif; ?>
    			        	<div class="brand-description text-center">
                            <p><?php echo wp_specialchars_decode( $brand->description ); ?></p></div>
                    	</a>
                    	<?php
    		        }
            	?>
    		</div>
        	<?php
        }
    }

    2) Add below code to child theme style.css

    .single-product-sidebar .sidebar-widget.product-brands {
        display: none;
    }
    .brand-description p {
        font-size: 14px;
    }

    3) Add below shortcode to Appearance > Widgets > Single product sidebar
    [product_brand_single]

    Regards

    Avatar: andrey-4923
    Andrey
    Participant
    November 26, 2021 at 00:04

    Hello,
    Thanks a lot!!! It works! ^.^
    Could you give me another advice please, how to rename the title “Product Brand” on product’s page?

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    November 26, 2021 at 13:36

    Hello,

    Edit the code I provided and change the title there
    <?php esc_html_e('Product brand', 'royal-core') ?>

    Regards

  • Viewing 6 results - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.