Remove Admin from Recent Comments List (No Plugin)

Last week, I had written how you could greet your first time commentators with a simple tweak. Here is another tweak with which you can remove your (admin) name from the Recent Comments list. And this time again, no plugins involved :)

I guess you are a bit confused on what we are going to do, the following images will explain.

Recent Comments: Before and After

Recent Comments: Before and After

Out-of-the-box: I saw the top commentator widgets on some blogs showing the author himself as the top commentator. There is an option to remove you from the list in the options of the Top Commentator Widget itself. Please write your name in that widget and get yourself removed.

Moving out of Recent Comments

This time again, we exploit the real meaning of open source Content Management System, we edit the Wordpress Core. Follow the steps. Written for Wordpress 2.7.1, steps must be similar in future versions too.

Find the file widgets.php in wp-includes folder.
Download the file and backup a copy, just in case.
Open the widgets.php in your favorite code editor. Notepad++ is my favorite.
Go to Line 1393 to find

$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");

Add a condition which delimits the fetch query from fetching a particular name. The code will look like:

$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' AND comment_author != 'YOUR-NAME-HERE' ORDER BY comment_date_gmt DESC LIMIT $number");

Replace YOUR-NAME-HERE with the display name of the admin. I used Arun Basil Lal.
Upload the file to the server, overwriting the old widgets.php file. That’s it.

Known Issues:

When a new Wordpress Update comes it might replace the widgets.php file with a new version. Then you will have to repeat this again.

Update: In WordPress 2.8.1 the target file is default-widgets.php in the same folder as widgets.php.

KishPress : Professional WordPress Tools

You May Also Like To Read:

  1. Greet First Time Commentators without a Plugin
  2. Finally, Here is a sure shot way to remove WordPress meta Generator Tags
  3. Add Custom Status or Notes to a Post without a Plugin
  4. If you have 1000+ comments awaiting moderation, this is for you
  5. Add the Fast Forward Button Right from the Post Editor

This entry was posted in WordPress and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

For More Like, "Remove Admin from Recent Comments List (No Plugin)"
Grab the Feed or,

26 Comments

  1. Posted March 15, 2009 at 21:06 | Permalink

    Good post. Now more wordpress users will be benefited by this one. Good thinking.

    • Posted March 15, 2009 at 23:03 | Permalink

      I was thinking of implementing this for a long time, this afternoon was the opportune moment! Hope the folks find it useful :)
      Cheers

  2. Posted March 17, 2009 at 05:04 | Permalink

    Thanks for the tip Arun! I’ll be implementing this tonight!

    • Posted March 17, 2009 at 17:53 | Permalink

      Make sure that you keep track of the updates you have made. Will have to repeat this with the next Wordpress update :(

  3. Posted March 17, 2009 at 07:19 | Permalink

    Arun,

    A good tweak,If the author of this plugin follow your line of thinking.This could have come as an option in plug in setting.Even I am planning to do the same very soon.

    • Posted March 17, 2009 at 17:54 | Permalink

      Actually it comes with Wordpress, yes, the coders at wordpress should have thought of this :)

  4. Posted March 17, 2009 at 12:07 | Permalink

    Great Post.but an experienced WordPress user will never try to touch the core files of WordPress.you can use any other advanced recent comments plugins out there.

    “But wordpress don’t update widgets.php with every update so you won’t have to repeat this every time”

    Please refer this page link is modified.

    • Posted March 17, 2009 at 18:16 | Permalink

      But people who love to handle code, like ex-programmers or core php freaks love to do it the code way rather than a plugin way. Ofcourse a plugin makes it lot easier, but where is all the fun?

      Thanks for that link, I had never noticed that. Kudos :)

  5. Posted March 17, 2009 at 23:35 | Permalink

    I have a number of websites and blogs, and I use WordPress for one of my blogs. WordPress is quickly becoming my blog management of choice, but it is more complicated to use (if you incorporate your own domain) than it is with other systems – Blogger, for example. That’s why I appreciate technology efficient bloggers like yourself who have the ability to give WordPress users detailed instructions on how to tweak their blogs. When you go into the WordPress core, that can be a scary thing. I hesitate to do it. However, if we have a technology efficient blogger giving us correct instructions on how to tweak – we can feel safer. I don’t know that I will need to put this particular WordPress tip into play. I’m satisfied with things right now. But thanks!

    • Posted March 21, 2009 at 10:34 | Permalink

      IMHO, Wordpress is not complicated. It is powerful and looks good, but its half as complicated as Blogger. Since Blogger is not opensource, the only thing that you get to play with is the code of the template. And there is a drag-and-drop layout editor for that, I guess thats what makes people think Blogger is simple.

      Trust me, you will fall addict to wordpress soon!
      Thanks for the good words,
      Welcome!

  6. Posted March 18, 2009 at 11:20 | Permalink

    This is great but i would like you to use author id instead of author name because, there might be case where you might have a guy with same name.

    I know it is hard to find arun basil lal. but for ex: in my blog i use nihar as the name (without sirname).

    • Posted March 21, 2009 at 10:58 | Permalink

      Good thinking, I will look into this and keep you posted soon!
      Thanks for the heads up, you are rocking :)

  7. Posted March 19, 2009 at 10:00 | Permalink

    Good tip Arun :) I also wanted to implement this for a long time, but my laziness got better of me each time.

    But these days i do not want to do this because, my comments as the admin might be what some people expect on a post as a reply to their query or something…not seeing it in the regular stream might piss them off sometimes :)

    • Posted March 20, 2009 at 23:07 | Permalink

      Anand,
      You have a point there. Actually I am using that to my advantage. I can stay invisible by removing my comments from the stream (evil me ;) )
      Moreover, if a commentator is expecting a reply, he would have already subscribed to future comments for the post. But as you said, some might assume that the admin never replies to comments at the first sight :(

      Cheers :)

  8. Posted March 29, 2009 at 10:19 | Permalink

    Nice one ! Gonna remove admin from mine too ! :)

    • Posted March 29, 2009 at 13:59 | Permalink

      make sure that you make a not of it, so that the next time wordpress updates, you wil still know what all to do.. :)

      • Posted March 29, 2009 at 15:09 | Permalink

        Sure..! ..
        But @ first I thought it was a plugin’s work ! ..
        But the coding is useful !..

  9. Posted June 18, 2009 at 22:06 | Permalink

    thanks Arun … setelah saya coba, kode tersebut berjalan dengan sangat baik … saya menambahkannya pada artikel yang kebetulan mengenai cara menambahkan recent comment di blog saya …
    I’m sorry … i can’t english :)

    • Posted June 18, 2009 at 22:14 | Permalink

      Google Translator cannot translate Malay to English, anyway I think its something good. Thanks for that anyway :)

  10. nobihai
    Posted June 20, 2009 at 20:24 | Permalink

    Thanks you very much.

  11. Posted June 30, 2009 at 08:47 | Permalink

    Recently I saw your name in Recent Comments ?

    Any intention ? SEO ?

    • Posted June 30, 2009 at 14:51 | Permalink

      Remember? it was a hack in the WordPress core. after the upgrade to 2.8 I havent changed it yet.. Am waiting for 2.8.1 to come out. Will change it once its here :)

  12. ezinonulan
    Posted July 1, 2009 at 06:48 | Permalink

    if u use 2.8, find that in comments.php

    • Posted July 1, 2009 at 09:32 | Permalink

      Ya, I have moved to 2.8, haven’t tweaked it yet, waiting for 2.8.1 to roll out. Thanks for the heads up :)

    • Posted July 10, 2009 at 22:36 | Permalink

      Hey, in WP 2.8.1 (and WP 2.8) the file to be edited is default-widgets.php, not comment.php.

      I just did that :)

  13. Posted March 18, 2010 at 00:33 | Permalink

    Thanks you very much.

One Trackback

  1. [...] filterisasi komentar admin, sumber: Remove Admin from Recent Comments List (No Plugin) dari blognya mas Arun Basil [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

  • Get Free Updates

Home · Archives · About · Contact · Advertise · Hire Me · RSS
© 2006 – the end of time, Arun Basil Lal. Powered by WordPress, H2O and an Awesome Bunch of Friends.