soderlind.no

I code for fun

WordPress plugin: Remove “Comments are closed”

| 10 Comments

On posts where comments are closed, the plugin will remove the text ‘Comments are closed.’ The plugin supports any languages/text domains, and will remove the text from themes and plugins.

Prerequisite: Since the plugin is filtering gettext, your theme/plugin must be localized.

The plugin is available in the WordPress plugin directory


Plugin source code:

<?php
/*
Plugin Name: Remove "Comments are closed"
Plugin URI: http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/
Description: On posts where comments are closed, the plugin will remove the text 'Comments are closed.' The plugin supports any languages/text domains, and will remove the text from themes and plugins.
Author: Per Soderlind
Version: 1.2
Author URI: http://soderlind.no/
*/

add_filter('gettext', 'ps_remove_comments_are_closed', 20, 3);

function ps_remove_comments_are_closed($translated_text, $untranslated_text, $domain) {
    if ( $untranslated_text == 'Comments are closed.' ) {
        return '';
    }
    return $translated_text;
}
?>

Changelog:

  • 1.2 removed unnecessary code
  • 1.1 initial public release

10 Comments

  1. I intstalled this Plugin. The “Comments Are Closed” tag still remains on my blog. Can you please help here.

  2. If I want my WP theme to be only English do i need to localize to? I am a very beginner and the article you are referring for localization is too difficult to implement. I just want to remove comments are closed without touching any code. why can;t i do it? thank you.

    • Hi Alex,

      No you don’t have to localize it yourself, but you must choose a theme that has localization code. If the text in the theme is wrapped in __() or _e() functions, you are fine.

      If you give me the url to where you found the theme, I can check this for you.

      Btw, the default themes, Twenty Ten an Twenty Eleven, has localization code.

  3. I installed, it, on newest version of WP, it appears it set my site to use a static home page, then I tried to de activate it, and it seems on de activation, it does not revert everything it did?

    • It doesn’t do anything to wordpress db etc, so turning it off will remove it.

      What’s the theme you’re running ? Are you running any caching plugins ? Any other new plugins added lately?

  4. Hi. I tried it with the mainstream (woo themes) theme and it did not work.
    No no other plugins, no caching plugins. Yours is the only one activated.
    So I take it, when you de activate it, it does not revert the changes it made? Tks

    • Most of the themes have their “internal plugins” aka THEMEFOLDER/functions.php, so for me to be able to see if there’s a conflict, I need to know which woo theme you’re using.

      The plugin (see code above) only filters gettext, the only reason that it doesn’t revert when you switch the plugin off is that your wordpress / theme is caching the output.

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Required fields are marked *.

*


Rodney's 404 Handler Plugin plugged in.