Hanbal Ishaq
Hanbal Ishaq

Reputation: 1

Display Product Category Description in WooCommerce between pagination and products

I'm currently facing an issue with my WooCommerce store and would appreciate any insights or solutions you might have.

Here’s what I’m trying to achieve: I want to display the product category description on my category pages, specifically below the pagination and above the product listings. I've been following various tutorials, but I haven’t had any success so far.

Here’s what I’ve done:

I located the archive-product.php file in my theme and made modifications to include the category description. I’ve used the following code in my archive-product.php file:

if ( is_product_category() ) : ?>
    <div class="category-description">
        <?php 
        echo term_description(); // Display the product category description 
        ?>
    </div>
<?php endif; 

What I’ve Observed:

I added a debug message to confirm that the archive-product.php template is loading, but I haven’t seen any output confirming this. I verified that I’m on the correct product category page, but the description still does not appear. My Environment:

I’m using the Active7 theme (child theme of The7).

Everything mentioned above

Upvotes: 0

Views: 113

Answers (1)

Muhammad Junaid Tariq
Muhammad Junaid Tariq

Reputation: 69

  1. Since you’re using a child theme of “The7”, WooCommerce templates might be overridden by the parent theme. First, ensure that archive-product.php is the correct file that WooCommerce is using.
  2. Check if the parent theme or child theme includes a file like taxonomy-product_cat.php or content-product_cat.php.

You can try this function

// Display category description below pagination and above product listings
add_action( 'woocommerce_before_shop_loop', 'display_category_description', 5 );

function display_category_description() {
    if ( is_product_category() ) {
        $term_description = term_description();
        if ( ! empty( $term_description ) ) {
            echo '<div class="category-description">' . $term_description . '</div>';
        }
    }
}

Upvotes: 0

Related Questions