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)