$25
Different dates for shutting off comments for different content
Howdy folks,
On CSS-Tricks I have comments on articles set to shut off after 2 months (or something like that). That is a global setting from the Admin area.
This also affects how long comments are open on Pages. For example, my screencasts use a special page template, which also includes templates. I am fine with closing comments on those after 2 months as well.
But then there are my "snippets", which use a different special page template. For THOSE, I'd like to leave comments open forever.
Anyone have a solution for that?
-Chris
On CSS-Tricks I have comments on articles set to shut off after 2 months (or something like that). That is a global setting from the Admin area.
This also affects how long comments are open on Pages. For example, my screencasts use a special page template, which also includes templates. I am fine with closing comments on those after 2 months as well.
But then there are my "snippets", which use a different special page template. For THOSE, I'd like to leave comments open forever.
Anyone have a solution for that?
-Chris
Chris Coyier | 12/23/09 at 3:06pm
| Edit
(2) Possible Answers Submitted...
-

Last edited:
12/29/09
6:18pmDan Davies says:There was a hack pre-2.7 that enabled you to disable your comments after a certain amount of time had passed - so with a bit of editing it might help you:
<?php
function close_comments( $posts ) {
if ( !is_category('snippets') ) { return $posts; }
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 60 * 24 * 60 * 60 ) ) {
$posts[0]->comment_status = 'closed';
$posts[0]->ping_status = 'closed';
}
return $posts;
}
add_filter( 'the_posts', 'close_comments' );
?>
-

Last edited:
12/23/09
5:45pm
This question has expired.
Current status of this question: Completed





