Product Page

WooCommerce Show Custom Content Above Product Name

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)

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER