How to remove author name from recent comments widget in WordPress

I recently started to use widgets in all my WordPress blogs. It’s really easy to add new features via widgets but some times you may need to make some changes.

For example: I decided to show recent comments in my blog: In the past I used to show the URLs to the comments.

But via WordPress widget, this was shown:

“Author Name” on “URL to the Comment”

Where I like to only have this:

“URL to the Comment”

I thought it will be easy to make this change but I was wrong. There is no option available in WordPress widgets that can change this. So I tried to find some other solution.

In order to show only the URL to the recent comments in WordPress using widgets, you will have to edit a WordPress core file.

The file name is: “widgets.php”

Update: I am Editing this article as this solution is no longer valid for the latest WordPress release.

Now instead of “widgets.php”, download/edit this file:

“default-widgets.php”

And it can be found here

\wp-includes

You need to search for this function in the “widgets.php” “default-widgets.php” file

function wp_widget_recent_comments($args) { function widget( $args, $instance ) {

Below this function, look the line that starts with this code:

echo ‘<li class=”recentcomments”>’ . sprintf(__(‘%1$s on %2$s’)

echo '<li class="recentcomments">' . /* translators

Now you have to change this

('%1$s on %2$s')

To this:

('%2$s')

Save the file “widgets.php“default-widgets.php” and upload it to your server. From now on, only the URL to the recent comment will be shown.

  1. WordPress Plugin: Send an Email Notification ONLY IF Someone Replies to My Comment
  2. WordPress: How to remove Elements from the Head Section: Via Editing the Core Files?
  3. How to Remove CleverPlugins Advertisement/News from WordPress Dashboard
  4. WordPress: Cannot get rid of All
  5. WordPress: How to remove the Index, Start, Next, Prev Link Elements

13 Responses to How to remove author name from recent comments widget in WordPress

  1. 120mm fan

    *:; I am very thankful to this topic because it really gives useful information *,;

  2. Outdoor

    online jobs are many but most of them does not pay well enough so choose an online job well ;`;

  3. ot

    Thanks admin :)

  4. For people who want to show comment content:

    The Echo command which I have mentioned in the post: go there and you will find functions like:

    get_comment_author_link() etc

    There is also a function:

    get_comment()

    I am pretty much sure that this is the function that fetches comment body from DB.

    I currently am not using this widget in my site: so I have not tried it.

    You just need to try few different coding changes in the Echo command mentioned above and I am sure that you will be able to pull the content body instead of comment URL.

  5. Dyce

    I also wanted to display the actual comment instead of the link. did anyone figure this out?

  6. sonia

    thanks for telling me how to remove the author name from the recent comments. excellent :)

  7. haydi bastir fener

    how can i comment_content to the recent comments list?

  8. osman

    thx bill. for 2.8 info. luv ya

  9. Bill

    Now that 2.8 is out, the new name of the file is “default-widgets.php”.

  10. Justin

    Thanks for the post. This has helped me to get much closer to what I’m looking to do: I want in my Recent Comments widget to display Commentator’s Name: Comment – but if “%1$s” is the commenter, do you know how can I find what string = comment?

  11. Truncal

    Thanks for the post. I was wondering where to find that file. Q. would you know how to modify it to add a class to the name? I would like to control the styles a bit better.

  12. Shafi

    I am using WordPress 2.6.3.
    How do I get a line-break like a between comments in the Recent Comments widget.
    I have this statement in widget.php file:

    $widget_title = sprintf( _c(‘%1$s: %2$s|1: widget name, 2: widget title’ ), $sidebar_args['widget_name'], $widget_title );

    Thanks
    Shafi

  13. I tried to find the code you mentioned, which is,

    “$widget_title = sprintf( _c(’%1$s: %2$s|1: widget name, 2: widget title’ ), $sidebar_args['widget_name'], $widget_title );”

    In the widgets.php, I was failed to find it [2.6.3].

    Anyway, open the widgets.php file which is in wp-includes and look for this code

    ->comment_post_ID) . ' < / a > ' ) . ' < / li > ' ;

    You need to add “< /*br > ” in the last part which is

    “'< / a > ') . '< /li > ';

    So the code which will give you one line break will be like this:

    ->comment_post_ID) . '< / a > ') . '< / li > < / br > ';

    NOTE: Remove all “*” “Asterisk”

    If you want more space, then add more line breaks

*