Created
May 7, 2020 12:17
-
-
Save serkanalgur/d19328a8f1a68af99c46ca0c43eabf6f to your computer and use it in GitHub Desktop.
30 Günden Eski Mesajlarınıza Yorum Yapılmasını Engellemek https://wpadami.com/cms-sistemleri/wordpress/30-gunden-eski-mesajlariniza-yorum-yapilmasini-engellemek.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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