Short and Long Discription in Woocommerce Product Category

Viewed 36

I want to have a short description and a long description on all my product category (Archive) pages. I have been able to move the product archive description to the bottom of the page using the code below:

// move Product category description to bottom of pages

remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );

What I also need is a short description to display at the top of every product archive page, but I have no idea how to do this. My current theme (OceanWP) doesn't give an option to have short and long descriptions on the product archive. What is the way around this?

1 Answers

You can try this snippet:

function myfunction_add_short_description_in_product_categories() {
    global $product;
    if ( ! $product->get_short_description() ) return;
    ?>
    <div itemprop="description">
        <?php echo apply_filters( 'woocommerce_short_description', $product->get_short_description() ) ?>
    </div>
    <?php
}
add_action('woocommerce_after_shop_loop_item_title', 'myfunction_add_short_description_in_product_categories', 5);

The above code will display the short description between the name and the price of the product. If you want to display the description below the price, you’ll have to change the action hook to woocommerce_after_shop_loop_item.

add_action('woocommerce_after_shop_loop_item', 'myfunction_add_short_description_in_product_categories', 5);

Please note: Ocean WP theme hooks override the WooCommerce hooks. If this solution does not give you the result you are looking for, the OceanWP has their own extension for hooks that may be beneficial for you. OceanWP Hooks

Related