Are you trying to remove dates from WordPress site of yours? Nowadays, there are several reasons that bloggers want to remove comment dates. One reason is to look at their comments as fresh and evergreen. If you want this feature in your blog, then this post is just for you.
In this post, I will show you how to remove dates from WordPress comments.
Let’s begin, then.
Remove Dates From WordPress Comments
Before you start, it is recommended to take a backup of your website before you edit code. You can always restore your website to an earlier stage at any time from the backup. If you don’t know how to take a backup, you can see this post’ How to Take a Backup of WordPress Website(Easiest Method)‘.
Method 1: Remove Dates with Better Recent Comments Plugin
From your WordPress dashboard, navigate to Plugins -> Installed Plugins and click on the ‘Add New Plugin’ button. Search for ‘Better Recent Comments’ plugin.
Install the plugin, and don’t forget to activate it. To get started, you don’t need any additional configuration. As soon as you activate the plugin, the date will be hidden.
Method 2: Remove Dates With Custom Coding
To remove dates from WordPress comments, at first navigate to Appearance -> Theme Editor and select functions.php.
Now paste the following code.
// Remove comment date
function wpb_remove_comment_date($date, $d, $comment) {
if ( !is_admin() ) {
return;
} else {
return $date;
}
}
add_filter( 'get_comment_date', 'wpb_remove_comment_date', 10, 3);
// Remove comment time
function wpb_remove_comment_time($date, $d, $comment) {
if ( !is_admin() ) {
return;
} else {
return $date;
}
}
add_filter( 'get_comment_time', 'wpb_remove_comment_time', 10, 3);
Don’t forget to hit the ‘update file’ button. Now visit any post on your website, and you will see that there is no date and time visible in the comments.
However, you may find that prepositions like ‘on’ or ‘at’ are visible in the post. To remove those, right-click on the preposition and select ‘inspect’.
Now note the CSS class in the div or span around the date/time in your theme. Then add the following CSS code to your theme, to hide those prepositions.
.comment-time {
display:none;
}
Note: here, ‘.comment-time’ is the class that I found in my theme; you may find any different class.
Now click on Save Changes and visit your website. You will find changes.
Last Words
Hope you have successfully removed dates from your comments. But remember this, this method doesn’t eradicate dates completely from the WordPress database. If you delete the code, the dates will be visible immediately. If you liked this post, you can see other posts on our blog, and you might like those too.
Please share the post with your friends and leave your thoughts in the comment box below.
Changelog
- Updated on 2024-12-19 (Uzzal Raz Bongshi)
- Added ‘Method 1: Remove Dates with Better Recent Comments Plugin’.
- Updated content details.
Leave a Reply