search ]

Add Content to WooCommerce Product Description

If you want to add content to WooCommerce product descriptions site-wide, use the following code. Add it to your theme’s functions.php file and change the text on line 5 as desired. Note that this code adds the information at the end of the product description content.

function change_woocommerce_description( $content ) {
    // Only for single product pages in woocommerce
    if ( is_product() ) {
        // The custom content to add
        $custom_content = '<p class="custom-content">' . __("This is the last line in the description", "woocommerce").'</p>';
        // Inserting the custom content at the end of the current product description
        $content .= $custom_content;
    }
    return $content;
}
add_filter( 'the_content', 'change_woocommerce_description' );

More on changing and adding fields to WooCommerce products in the post How to add custom fields to the WooCommerce product page.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo