- This topic has 12 replies, 4 voices, and was last updated 2 years, 11 months ago by Charbel.
-
AuthorPosts
-
November 27, 2020 at 4:32 pm #1553715Baz
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 #1555381TomLead 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 🙂
November 28, 2020 at 12:01 pm #1555412BazHi 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 #1555623LeoStaffCustomer SupportCan you give this CSS a shot?
.comment-author-info a { pointer-events: none; color: #000000; }
November 28, 2020 at 4:21 pm #1555630BazWorked perfectly! Thanks Leo 🙂
November 28, 2020 at 4:39 pm #1555653LeoStaffCustomer SupportNo problem 🙂
May 7, 2021 at 3:01 am #1768623CharbelHope 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 #1770583TomLead 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.
May 9, 2021 at 12:56 am #1770949CharbelHello @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 #1771539TomLead 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”.
May 9, 2021 at 10:15 am #1771549CharbelThank 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 #1772899TomLead DeveloperLead DeveloperNo ETA yet – it’s a big one!
Glad that option helped 🙂
May 10, 2021 at 7:45 am #1772911CharbelThank You @Tom!
-
AuthorPosts
- You must be logged in to reply to this topic.