Site logo

Archived topic

Remove Author Link from Comments

7 replies · Started by Jesse on January 3, 2021

Viewing posts 1–8 of 8

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,
Jesse

Hello,

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,
Jesse

Use 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() to get_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 the generate_do_comment_reply_link function to keep the default way of adding the reply link.

Hello,

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,
Jesse

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?

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. :)

Hello,

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!

Glad you got it sorted. No problem. :)

This archived topic is closed to new replies.