- This topic has 12 replies, 4 voices, and was last updated 1 year, 1 month ago by
Charbel.
-
AuthorPosts
-
November 27, 2020 at 4:32 pm #1553715
Baz
Hi guys, I want to remove the comment author’s url link from the comments section (not the comments form), and also the comments date/time. I could probably do this with CSS, but hopefully there’s a function somewhere!
I would also like to add some text after the ‘Leave a Comment’ title e.g. “Your email address and website details will not be published”.
Thanks.
November 28, 2020 at 11:41 am #1555381Tom
Lead DeveloperLead DeveloperHi there,
Unfortunately, the only way to do this without CSS is to overwrite the entire function responsible for displaying the comments: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/comments.php#L12-L91
That’s not ideal, as you’d need to keep it updated if we change anything within it during an update.
We can, of course, disable the links using CSS very easily.
You should be able to change that text like this:
add_filter( 'generate_leave_comment', function() { return 'Leave a Comment - Your email address and website details will not be published'; } );
Let me know 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 28, 2020 at 12:01 pm #1555412Baz
Hi Tom.
I was able to change the ‘Leave a Comment’ text with your snippet. I can remove the date/time with CSS but having a little trouble targeting the author url. Any help/tips will be much appreciated.
I normally use the Genesis theme which has a filter to remove the author url.
Thanks.
November 28, 2020 at 4:17 pm #1555623Leo
StaffCustomer SupportCan you give this CSS a shot?
.comment-author-info a { pointer-events: none; color: #000000; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/November 28, 2020 at 4:21 pm #1555630Baz
Worked perfectly! Thanks Leo 🙂
November 28, 2020 at 4:39 pm #1555653Leo
StaffCustomer SupportNo problem 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 7, 2021 at 3:01 am #1768623Charbel
Hope you are doing well.
I came across the same request noted here. I have implemented the CSS code noted below.
.comment-author-info a { pointer-events: none; color: #000000; }
The author URL link and comment date/time got removed, however, Google PageSpeed Insights is still complaining about: Avoid an excessive DOM size for author URL and date and time.
Example:
Maximum DOM Depth
April 23, 2021 at 1:59 pm
<time datetime=”2021-04-23T13:59:43+02:00″ itemprop=”datePublished”>I was able to fix the author URL link by removing it completely using the following function:
add_filter( 'get_comment_author_link', 'rv_remove_comment_author_link', 10, 3 ); function rv_remove_comment_author_link( $return, $author, $comment_ID ) { return $author; }
However, I still need to do the same (remove only #hyperlink) for date/time as well.
Could you please help with achieving that? (comments.php)
Single post example here: https://charbelnemnom.com/sc-200-exam-study-guide-microsoft-security-operations-analyst/
Your help is highly appreciated!
Thank You!
-CharbelMay 8, 2021 at 10:27 am #1770583Tom
Lead DeveloperLead DeveloperHi there,
I’m not seeing a hyperlink for date/time anywhere – can you point me in the right direction?
A link isn’t going to trigger the Maximum DOM Depth problem – that only happens when you have a ton of elements nested inside each other (think page builders). Not sure how it applies here.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 9, 2021 at 12:56 am #1770949Charbel
Hello @Tom,
Thank you for your kind reply!
I took out / removed line 47 from the comments.php to remove the hyperlink for date/time from all comments. For this reason, you are not seeing the hyperlink anymore.
https://github.com/tomusborne/generatepress/blob/3.0.3/inc/structure/comments.php#L47
Then, I have added the following code in funtions.php to remove the Author hyperlink from all comments as well.
add_filter( 'get_comment_author_link', 'rv_remove_comment_author_link', 10, 3 ); function rv_remove_comment_author_link( $return, $author, $comment_ID ) { return $author; }
After I removed the Hyperlink for the date/time + author, Google PageSpeed insight is complaining now about:
Maximum DOM Depth | Element (Author Name) <cite itemprop=”name” class=”fn”>. footer.comment-meta Line 43:
https://github.com/tomusborne/generatepress/blob/3.0.3/inc/structure/comments.php#L43
How to solve the Maximum DOM Depth for the comments section, please?
I have another one for Maximum Child Elements that’s coming from JetPack Social media sharing option.
Thank You Tom!
-CharbelMay 9, 2021 at 10:08 am #1771539Tom
Lead DeveloperLead DeveloperWe’ll be adding a filter to the output of that element so you can remove the link without altering core files in 3.1.0.
The DOM thing could be the nested comments you have in that article – you can limit the depth of comment nesting in “Settings > Discussion”.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 9, 2021 at 10:15 am #1771549Charbel
Thank you @Tom for the update, much appreciated!
Looking forward to the new filter update in 3.1.0. Is there any ETA on when this update will be released?
In the meantime, I removed Enable threaded (nested) comments levels deep in “Settings > Discussion” to solve the DOM Elements.
Many Thanks and keep up the good work!
-Charbel
May 10, 2021 at 7:38 am #1772899Tom
Lead DeveloperLead DeveloperNo ETA yet – it’s a big one!
Glad that option helped 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 10, 2021 at 7:45 am #1772911Charbel
Thank You @Tom!
-
AuthorPosts
- You must be logged in to reply to this topic.