Home › Forums › Themes Support › How to display category or tag description in WooCommerce
- This topic is empty.
-
AuthorPosts
-
July 7, 2023 at 2:28 am #11650
Hi all customers,
In this topic tutorial we’ll help you display description of category or tag in WooCommerce.
Default description of Category or Tag doesn’t allow HTML tag in input field.
Step 1: You need allow HTML tag in description by follow this tutorial from WooCommerce:
Please go to functions.php or parent theme or child theme and add this code:
/** * Allow HTML in term (category, tag) descriptions */ foreach ( array( 'pre_term_description' ) as $filter ) { remove_filter( $filter, 'wp_filter_kses' ); if ( ! current_user_can( 'unfiltered_html' ) ) { add_filter( $filter, 'wp_filter_post_kses' ); } } foreach ( array( 'term_description' ) as $filter ) { remove_filter( $filter, 'wp_kses_data' ); }
Step 2: Then you can insert HTML in description of tag or category like this:
The description is not prominent by default; however, some themes may show it. <img src="https://pangja.local/wp-content/themes/pangja/framework/admin-assets/images/theme-options/logo.png">
Step 3: go to theme-folder/woocommerce/ then open file archive-product.php or another files depend on the theme you are using.
Use this code to display desription:
<?php if ( strip_tags(term_description()) ) : ?> <div class="product-term-description"><?php echo term_description(); ?></div> <?php endif; ?>
Step 4: Go to Appearance -> Customize -> Additional CSS to add CSS code if needed.
Hope this helps and thanks for reading!
****
Regards,HaruTheme
-
AuthorPosts
You must be logged in to reply to this topic.