Skip to content

How to replace wordpress comments count number and text?

How to replace wordpress comments count number and text?

How to Replace WordPress Comments Count Number and Text

Today we are going to see how to replace the wordpress comments count number and text with just a few lines of code. Sometimes our clients demand us to change wordpress comments text like [0 Comment] to [0 Comments]. But there is no such plugin available to make these changes. So, we have to do hard code for this change.  Also, make sure you have knowledge about PHP, WordPress Hooks, Functions otherwise you will break your site and we are not responsible for this. Without the proper knowledge, there is a 100% risk for your site. If you are a beginner and don’t want to take that risk then we will suggest you hire someone else or hire our experienced web developer. We also provide web development services. So, you don’t need to find someone else in the marketplace just Contact us through our website we will get in touch with you within a few minutes.

First of all, before we make any changes we need one plugin called Code Snippets. After installing it please activate it. Then go to Snippets

Code snippets

After that click on Add New and give a title name. Example: Replace WordPress Comments Counts and Texts

replace wordpress comments count and text

Then apply the below codes and make changes based on your client’s requirements.

add_filter ('comments_number', 'wpcodersclub_comments_number', 10, 2);
function wpcodersclub_comments_number ($output, $number) {
if ($number == 0) $output = '0 Comments';
elseif ($number == 1) $output = '1 Comment';
else $output = $number . ' Comments';
return $output;
}

Save changes and activate code snippets

We are going to help you to improve your wordpress coding skills throughout our experience.

Leave a Reply

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