admin管理员组

文章数量:1289581

I would like to totally remove all the hyperlinks that my comments on wordpress are making. I've almost removed all the hyperlinks, but there is one left.

It is this one :

<span class="time"><a href="#comment-<?php comment_ID() ?>"></a></span>

Is there a way to add a custom php code in my functions.php file that would delete all this span class?

Thanks in advance!

I would like to totally remove all the hyperlinks that my comments on wordpress are making. I've almost removed all the hyperlinks, but there is one left.

It is this one :

<span class="time"><a href="#comment-<?php comment_ID() ?>"></a></span>

Is there a way to add a custom php code in my functions.php file that would delete all this span class?

Thanks in advance!

Share Improve this question edited Jul 14, 2021 at 15:20 Edouardo asked Jul 14, 2021 at 12:13 EdouardoEdouardo 11 bronze badge 6
  • How about using strip_tags on the final string? – Buttered_Toast Commented Jul 14, 2021 at 12:17
  • @Buttered_Toast I've tried with a lot of codes including strip_tags that I've found on the internet for 4-5 days (I'm not a dev so usually I search for example of codes and I try to adapt it to my case) but it broke my site almost every time – Edouardo Commented Jul 14, 2021 at 12:35
  • Are you hooking into a filter? where does this code come from? what code did you use to strip all the other tags? did you edit a .php file? it's hard to help without knowing from where this code comes from of what you already tried to do – Buttered_Toast Commented Jul 14, 2021 at 12:57
  • Oh, yes, sorry! I'm not hooking it into a filter, I don't really know how to use them! This code comes from the comments.php file of my theme! The only thing that is working, is if I delete all this code from the comments.php file of my theme, but since my theme is updated almost every 3-4 days my modifications are removed every time. That's why I'm searching a code that I could put into my functions.php plugin that would remove this code from comments.php – Edouardo Commented Jul 14, 2021 at 13:05
  • 1 Ohhh, thats exactly what child theme is for, if the theme was made with the option for child theme (most of them do), you can create a child theme with the comments.php file in it and do all the changes there. search for how to create a child theme, you will find alot of resources about this – Buttered_Toast Commented Jul 14, 2021 at 13:08
 |  Show 1 more comment

1 Answer 1

Reset to default 0

You shouldn't be stripping this via the functions.php file but rather edit the comments.php to remove the span directly.

If this is a commercial theme that receives updates then you should do it by creating a child theme and customizing your functions.php & comments.php in that child theme.

This is a great tutorial on how to do that: https://www.smashingmagazine/2016/01/create-customize-wordpress-child-theme/

本文标签: commentsHow to remove a span class