In this WooCommerce snippet, we’ll learn how to insert custom content between the price and a short description on the single product page. This customization can be useful for displaying additional information about the product or promotional messages to capture customer attention.
/**
* Snippet Name: Add Custom Content Between Price and Short Description on Single Product Page
* Snippet Author: wpsnippets.dev
*/
// adding content between price and description
function custom_content_between_price_and_description() {
// Output your custom content here
echo '<div class="custom-content">This is a custom message or additional information.</div>';
}
add_action('woocommerce_single_product_summary', 'custom_content_between_price_and_description', 25);
Code Explanation
- This snippet hooks into the woocommerce_single_product_summary action with a priority of 25. It adds a function custom_content_between_price_and_description() that echoes your custom content.
- Adjust the content inside the function to display whatever information you want to appear between the price and the short description.