WooCommerce Show Custom Content Above Product Name

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This quick guide shows you how to display custom content above the product title on the single product template using the woocommerce_single_product_summary hook. You may need to tweak the priority number to change the positioning of the custom text. If you need to display the custom content on a specific product, wrap the echo output in the appropriate is_single() if statement to test against the product ID. Let us know in the comments how you get on!

				
					/**
* Snippet Name: WooCommerce show custom content above product title
* Snippet Author: ecommercehints.com
*/

function ecommercehints_content_above_product_name() { 
   echo 'Custom content here!'; 
};

add_action( 'woocommerce_single_product_summary', 'ecommercehints_content_above_product_name', 1);
				
			

What About For A Specific Product?

				
					/**
* Snippet Name: WooCommerce show custom content above product title for a specific product
* Snippet Author: ecommercehints.com
*/

function ecommercehints_content_above_product_name() { 
if (is_single('31')) { // The product ID to show the custom content
   echo 'Custom content here!'; 
}};

add_action( 'woocommerce_single_product_summary', 'ecommercehints_content_above_product_name', 1); // Custom text appearing but not above title? Change this number (priority)
				
			
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers