Skip to content

Instantly share code, notes, and snippets.

@serkanalgur
Created May 7, 2020 12:17
Show Gist options
  • Save serkanalgur/d19328a8f1a68af99c46ca0c43eabf6f to your computer and use it in GitHub Desktop.
Save serkanalgur/d19328a8f1a68af99c46ca0c43eabf6f to your computer and use it in GitHub Desktop.
<?php
/**
* Yazı İsmi : 30 Günden Eski Mesajlarınıza Yorum Yapılmasını Engellemek
* Yazı Linki : https://wpadami.com/cms-sistemleri/wordpress/30-gunden-eski-mesajlariniza-yorum-yapilmasini-engellemek.html
*/
function close_comments($posts)
{
if (!is_single()) {
return $posts;
}
if (time() - strtotime($posts[0]->post_date_gmt) > (30 * 24 * 60 * 60)) {
$posts[0]->comment_status = 'closed';
$posts[0]->ping_status = 'closed';
}
return $posts;
}
add_filter('the_posts', 'close_comments');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment