Archived topic
Remove Comment Date and Time - Using comments.php
33 replies · Started by Jesse on February 18, 2021
Hello,
I'm using this comments.php in my child theme: https://docs.generatepress.com/article/move-the-comment-form-above-comments/
I want to completely remove (not hide) the comment date and time stamp, along with the "| Edit" link if you are logged in as admin. Please see the attached screenshot to see exactly what I want to remove.
How would I modify the above comments.php in order to accomplish this?
Best regards,
Jesse
Hi there,
There's no need to edit any files to do this.
You can completely remove these from the customizer settings.
On Appearance > Customize > Layout > Blog, you'll find checkboxes to display comment count and display post date. You can uncheck them for both Archive and Post pages if you don't want them to display for both.
Note: This completely removes the dates and comment links from being included to the DOM structure. If you inspect your page after applying this, you'll see that the actual HTML structure for these are completely excluded.
Elvin,
I do not have a “Display Comment Count” option and the “Display Post Date” option is to turn on or off the POST date.
I am wanting to remove the date and time and edit links that appear under each comment as explained in my original post.
Best regards,
Jesse
I do not have a “Display Comment Count” option and the “Display Post Date” option is to turn on or off the POST date.
Perhaps your Blog module is not enabled.
Can you check under Appearance > GeneratePress if your "Blog" module is enabled as shown here?
https://share.getcloudapp.com/kpu76Ryw
Yes, the Blog module is enabled.
That's strange, the option shown here - https://share.getcloudapp.com/WnuBk8JQ - should be visible once you've enabled the Blog module.
Can you try disabling ALL plugins except GP Premium to check if its caused by a plugin conflict?
Let us know.
Respectfully, how will disabling the “Display POST Date” option remove the date and time stamp from the COMMENTS?
Although I don’t see the “Display Comment Count” option for some reason, I do have the “Display Post Date” option. By disabling that option, it removed the publish date from the top of my post. This setting has nothing to do with the date and time stamp in the comments section from what I can tell.
Best regards,
Jesse
Hi there,
see Toms reply here:
Thanks, David.
I read that post last night and I see that Tom provided a comments.php to use, but would that solution work for me? Because I’m already using a different comments.php in my child theme (the one that I linked to in my original post).
I’m wondering if we need to modify the existing comments.php that I’m already using?
Best regards,
Jesse
Ideally, we need to add some filters in there to make this easier/prevent the need for a child theme template.
Can you share your current comments.php file (using a GitHub gist would be great)? That way I can suggest the necessary changes.
Hi Tom,
This is the exact comments.php that I'm using: https://docs.generatepress.com/article/move-the-comment-form-above-comments/
Thanks so much!
Best regards,
Jesse
So that function doesn't actually have the date/time in it. That can be found here: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/comments.php#L21
However, there is no filter to remove those elements right now, so you'd need to overwrite the entire function. That would be kind of a shame in order to do something so small.
What I would suggest is using CSS to hide the date/time for now, and we will have the necessary filters in 3.1.0 in order to fully remove them without overwriting the entire function.
Of course, if you're required to remove it now, you can overwrite the entire function by copying it: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/comments.php#L12-L91
Then paste it into your child theme functions.php file, and remove the date/time: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/comments.php#L47-L58
Thanks, Tom. Very helpful!
Do you have an ETA on v3.1.0?
Best regards,
Jesse
Would love to get it out in March - will do our best :)
Hello Tom,
Just to confirm, the filter will allow complete removal of the comment date and time entirely? Not just removal of the date and time link?
Best regards,
Jesse