Add Text After or Before Product Title in Woocommerce
Add Text After or Before Product Title in Woocommerce
HOME
WORDPRESS HOW TO ADD TEXT AFTER OR BEFORE PRODUCT TITLE IN WOOCOMMERCE?
AMAN MEHRA
AUGUST 13, 2021
LEAVE A COMMENT
Tweet on Twitter
Share on Facebook
SUBSCRIBE
RECENT POSTS
So as you know woocommerce is the most popular eCommerce platform to How to Hide Admin Bar in
build the online store with WordPress. The woocommerce plugin is free of cost WordPress?
but there are more plugins that are paid. You can use them to enhance the
functionality. It is up to you, you want to use it or not.
There are many customizations available in the woocommerce plugin using the
action/hooks. You can customize the functionality which is customizable. Like
CATEGORIES
you can also add text after or before add to cart button, make custom product
view counter and redirect to checkout, etc. Git
How To
So today, we will customize the product title on a single page by adding the text
JavaScript
after or before it. And also on woocommerce shop archive page.
Laravel
But there is no specific action or filter hook in woocommerce for the product title PHP
to customize it directly but still have a solution, you can customize it using the
Python
other action hooks. We will see this in the below tutorial.
ReactJS
Let’s get started.
WooCommerce
Before starting to add text after or before woocommerce product title, let’s see WordPress
let’s now start to add text after the product title. How can I Prevent SQL Injection in
PHP?
Table of Contents
1
Add Text After the Product Title
TIPS & TRICKS
2
Add Text Before the Product Title
Add Custom Columns to Laravel
2.1
Using the woocommerce_single_product_summary
Models Using Accessors
2.2
Using the woocommerce_before_single_product_summary
Delete a Line in Text File Using
3
Add Text After or Before on the Shop Page/Archive Page
Python
Add Text After the Product Title Get Current Page URL in PHP
Syntax: do_action('woocommerce_single_product_summary',
$post, $product);
Now we will use this same action hook to add text after product title. So let’s
now make the function hook.
In the above code, first, we removed the default product title using the
remove_action() function. Then we make our custom function to append
custom text to the product title.
We used the the_title() function and concatenate our custom code variable in it.
So add the above code snippet to your child’s theme and save it. It will show you
the custom text after the product title and further you can style it using the CSS
as per your requirements.
After adding the code, you will see the product title and custom text like in the
following image.
To add the before the text to the product title, we have two ways to do this. First,
we will use the same action hook as we did for “after product title” and second
for using the woocommerce_before_single_product_summary . Both
the ways work fine and the result will be the same as the text before the product
title.
It will be the same process as we did above. We just have to change the
concatenation variable position. In the above code snippet, we concatenate it
with the “after” parameter but in this method, we will concatenate it with the
“before” parameter. See the following code snippet.
So let’s add the text before the product title using this hook.
1 add_action( 'woocommerce_before_single_product_summary'
2
3 function add_custom_text_before_product_title() {
4 echo '<span>My Custom Text</span>';
5 }
So add the one code snippet from above both of them in your theme’s
functions.php file and save it. And you will see the screen like the below image.
OK, so all the above code snippets are only for woocommerce single product
page.
But what if you same things also want on the shop page or product archive
page?
Then you have to make another action hook to achieve the same functionality
on the shop page. We will make a hook for all looped products to customize the
loop product title and add custom text with it.
1 remove_action( 'woocommerce_shop_loop_item_title','wooco
2
3 function customize_shop_page_product_title() {
4
5 $custom_text = 'My Custom Text';
6 echo '<h3 class="woocommerce-loop-product__title">'
7
8 }
9 add_action('woocommerce_shop_loop_item_title','customize
In the above code, we make an action hook for the loop product and did the
same thing, product title concatenates with custom text variable. But in this
case, we use the get_the_title() function because now we are customizing the
title in the loop.
So save the code and you will see the result same as the below image.
Hope you understand, how you can customization in woocommerce and add
custom text after or before the product title.
If you have still have questions please ask me in the comment section. I would
like to help you with that.
ADD TEXT AFTER PRODUCT TITLE ADD TEXT AFTER PRODUCT TITLE WOOCOMMERCE
ADD TEXT BEFORE PRICE WOOCOMMERCE ADD TEXT BEFORE PRODUCT TITLE
PRODUCT TITLE BEFORE TEXT PRODUCT TITLE CUSTOMIZATION
TEXT BEFORE PRODUCT TITLE WOOCOMMERCE ADD TEXT AFTER PRODUCT TITLE
WOOCOMMERCE ADD TEXT BEFORE PRODUCT TITLE WOOCOMMERCE ADD TEXT BEFORE TITLE
WOOCOMMERCE PRODUCT TITLE FILTER WOOCOMMERCE PRODUCT TITLE HOOK
WOOCOMMERCE SINGLE PRODUCT PAGE TITLE
Tweet on Twitter
Share on Facebook
LEAVE A REPLY
Your email address will not be published. Required fields are marked *
Comment
Save my name, email, and website in this browser for the next time I comment.
POST COMMENT
Your Blog Coach is the best site Blog How to Add Text After or Before
Name
for finding the solution to any Product Title in WooCommerce?
Categories
issue related to coding and learn
How to Optimize Images Without Your email address
more cool stuff and tricks. Contact
Losing Quality to Increase
About Website Speed?
SUBSCRIBE
How to Disable Widget Block
Editor (Gutenberg) in WordPress?