- This topic has 7 replies, 2 voices, and was last updated 3 years, 3 months ago by Elvin.
-
AuthorPosts
-
January 3, 2021 at 2:15 pm #1604190Jesse
Hello,
I added the following code to my child theme functions.php, which did a great job at removing the author link in the comments section, but it also removed the reply link. I would like to keep the reply link. Can this code be updated to keep the reply link?
https://gist.github.com/generatepress/6a9ad4e007ae0a7388bbbbb7b3ae068f
Best regards,
JesseJanuary 4, 2021 at 12:49 am #1604471ElvinStaffCustomer SupportHi,
You can change your code to match this file’s Line 12 to Line 93. (This is the default comments.php file)
https://github.com/tomusborne/generatepress/blob/master/inc/structure/comments.php#L12You then change
get_comment_author_link()
to match what you did on your code by replacing it withget_comment_author()
.Note: You should be using template files for this instead of functions.php for good housekeeping.
January 4, 2021 at 5:18 am #1604777JesseHello,
I’m sorry, I’m not understanding your message.
I’m using this comments.php file (not the default comments.php file) in my child’s theme folder, which was used to move the comment form above the comments:
https://docs.generatepress.com/article/move-the-comment-form-above-comments/
And then I added this bit of code to my child’s functions.php file, which removed the author link as I wanted, but it also removed the reply link:
https://gist.github.com/generatepress/6a9ad4e007ae0a7388bbbbb7b3ae068f
So now, I just want to add the reply link back. Can you please let me know exactly what I need to do? Also, you mentioned something about using “template files” instead of the functions.php file. Can you clarify?
Best regards,
JesseJanuary 4, 2021 at 4:26 pm #1605685ElvinStaffCustomer SupportUse this on your child theme’s comments.php.
https://gist.github.com/ejcabquina/76199e5139a0216507822b33382c9d51
This code is directly taken from the default comments.php of the theme. I only changed
get_comment_author_link()
toget_comment_author()
to remove the author link.I’ve also kept the
do_action( 'generate_before_comment_text', $comment, $args, $depth );
,add_action( 'generate_after_comment_text', 'generate_do_comment_reply_link', 10, 3 );
and thegenerate_do_comment_reply_link
function to keep the default way of adding the reply link.January 4, 2021 at 5:12 pm #1605716JesseHello,
To recap, I was using this code for my comments.php to move the comment form above the comments (https://docs.generatepress.com/article/move-the-comment-form-above-comments/) plus this code in my functions.php to remove the author link which also removed the reply link (https://gist.github.com/generatepress/6a9ad4e007ae0a7388bbbbb7b3ae068f).
I went ahead and removed the above code from my functions.php and then replaced my comments.php file with the one that you provided in your last message, but it caused a critical error on the website so I had to revert back.
I’m still at square one. Can you please advise exactly what I need to do/change in order to add the reply link back?
Best regards,
JesseJanuary 4, 2021 at 7:15 pm #1605795ElvinStaffCustomer SupportI’m still at square one. Can you please advise exactly what I need to do/change in order to add the reply link back?
If I may suggest a really simple solution:
If the goal is solely to remove the comment author link, you can remove the gist code you’re using and simply strip its tags with a snippet so it displays as a text, not a link.
function disable_comment_author_links( $author_link ){ return strip_tags( $author_link ); } add_filter( 'get_comment_author_link', 'disable_comment_author_links' );
This solution is short and simple. This doesn’t require you to use complicated code AND it doesn’t mess up the reply link. 🙂
January 4, 2021 at 8:30 pm #1605836JesseHello,
I removed the Gist code that was in my functions.php and then added the snippet you provided above and it worked perfeclty. The reply link is back and the author name isn’t a link.
Thanks!
January 4, 2021 at 9:34 pm #1605883ElvinStaffCustomer SupportGlad you got it sorted. No problem. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.