# Long Description Shortcode for Woocommerce

Would you like to include a detailed and long description of your product in a custom accordion rather than using the default style of your WordPress theme? So, this article is for you.

<div align="left"><figure><img src="https://flatzone.cc/wp-content/uploads/2023/03/long-description-woocommerce-shortcoode-300x267.png" alt="" width="375"><figcaption><p>Long description</p></figcaption></figure></div>

Adding this code to your WooCommerce site is easy and will allow you to create a shortcode to display the product description for any product.

```php
// Create a shortcode for product description of Woocommerce

add_shortcode( 'product_description', 'display_product_description' );
function display_product_description( $atts ){
$atts = shortcode_atts( array(
'id' => get_the_id(),
), $atts, 'product_description' );

global $product;

if ( ! is_a( $product, 'WC_Product') )
$product = wc_get_product($atts['id']);

return wpautop($product->get_description());
}
```

Here are the steps you should take to add the code:

{% hint style="success" %}
1. Log into your WordPress dashboard and navigate to the ‘Appearance’ section.
2. Click on the ‘Editor’ option.
3. In the right-hand pane, select the ‘functions.php’ file.
4. Copy and paste the code snippet provided above into the file.
5. Click on the ‘Update File’ button to save your changes.
{% endhint %}

Once you’ve saved the changes to the functions.php file, you will now be able to use the shortcode <mark style="color:red;">**`[product_description]`**</mark>  wherever you need to display the product description. And, you’re also able to enter the product’s ID in the shortcode (e.g. ‘<mark style="color:red;">**`[product_description id=123]`**</mark> ’) to get the exactly Product ID. In case you’re adding it directly to the product page, no need to add the product\_id.

<div align="left"><figure><img src="https://flatzone.cc/wp-content/uploads/2023/03/long-description-woocommerce-shortcoode-custom-300x163.png" alt="" width="375"><figcaption><p>What you see in UX Builder</p></figcaption></figure></div>

{% hint style="success" %}
That’s it! You’ve now successfully added the code snippet to your WooCommerce site.
{% endhint %}
