When executed this tag will change all open comments to closed comments on posts that are too old. This is controlled by an attribute on the tag or by the number of days for the main index.


MTCloseComments executes an SQL query that closes comments for posts for entries that were created more than a certain number of days ago and have open comments. This should be sufficiently fast that it can be done every time the main index template is executed.

The attributes recognized by MTCloseComments are

If the old attribute is set to a numeric value then comments are closed for posts more than that many days old. If the attribute is not present then the tag looks up number of days for posts on the main index from the weblog configuration and posts older than that have their comments closed.

This prohibits closing comments on posts that have recently modified. A post must have been unmodified more than the number of days specified by this attribute to have its comments closed. The default value is 0 which effectively disables the test.

If this attribute is used with a non-empty string, then debug output will be generated. This will describe the successful operation of the plugin (parameters, number of comments closed) or one of a variety of error conditions. If the debug value contains the letter 'q' and no errors occur then the literal query string will be placed in the output.

The tag only closes comments for posts for which comments are open. Posts for which comments are disallowed are not closed.

While this tag normally generates no output, if you set the attribute debug to a value then it will generate text in all cases with either details on its actions or failures.


<MTCloseComments old="21">

Close comments for posts more than 21 days old.


Close comments for posts that are too old to appear on the main index.

<MTCloseComments inactive="3">

Close comments for posts that are not on the front page and have been inactive for at least three days.

<MTCloseComments old="7" inactive="3">

Close comments for posts at least 7 days old and inactive for three or more days.


Movable Type

MTCloseComments works with Movable Type version 2.6 or later.

  1. Copy the ``'' file into your Movable Type ``plugins'' directory. The ``plugins'' directory should be in the same directory as ``mt.cgi''; if it doesn't already exist, use your FTP program to create it. Your installation should look like this:
        (mt home)/plugins/

  2. The best way to activate MTCloseComments on your weblog is to edit your main index template and put the MTCloseComments tag somewhere in the template. The actual location is irrelevant since the tag doesn't generate output. For efficiency reasons the tag should not be placed inside any container tags so that it is executed only once while building the main index.

  3. (Optional) In the standard MT distribute, the modified value of a post is changed only by directly editing the post. To make posting a comment update the post modification time (which is used by inactive) you must add a line to MT/lib/App/ around line 106.
        $entry->save; # <-- ADD THIS LINE
        $app->rebuild_indexes( Blog => $blog )



To file bug reports or feature requests (other than topics listed in the Caveats section above) please send email to:

You should add the debug attribute to the tag and retrieve the output, or the error message you get from MT when rebuilding.

Version History

Version 1.0.0
19 Oct 2003 - Initial Beta Release

Version 1.0.1
12 Nov 2003 -
Version 1.0.2
18 Apr 2004 -
Version 1.0.3
21 Apr 2004 -


    Alan M. Carroll

Additional Credits

Copyright and License

    Copyright (c) 2003 Alan M. Carroll
    All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name ``MTCloseComments'' nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors ``as is'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.