2

I would like to know how would one add the category description underneath the category title on the woocommerce shop by category page? Here is what I've tried"

function woocommerce_after_shop_loop_item_title_short_description() {
    global $product;

    if ( ! $product->post->post_excerpt ) return;
    ?>
    <div itemprop="description">
        <?php echo apply_filters( 'woocommerce_short_description', $product->post->post_excerpt ) ?>
    </div>
    <?php
}
add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_after_shop_loop_item_title_short_description', 5);

but this doesn't show the cat description under the category title in the shop page any help would be greatly appreciated.

enter image description here

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399

1 Answers1

2

To display loop product category item description below the title, use one of the following:

Inside the term link:

add_action('woocommerce_after_subcategory_title', 'display_short_description_after_shop_loop_item_title', 10 );
function display_short_description_after_shop_loop_item_title( $category ) {
    if ( $description = $category->description ) {
        echo '<p class="'. $category->slug .' cat-description" itemprop="description">' . $description . '</p>';
    }
}

Outside the term link:

add_action('woocommerce_after_subcategory', 'display_short_description_after_shop_loop_item_title', 20 );
function display_short_description_after_shop_loop_item_title( $category ) {
    if ( $description = $category->description ) {
        echo '<p class="'. $category->slug .' cat-description" itemprop="description">' . $description . '</p>';
    }
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399