Skip to content

Instantly share code, notes, and snippets.

@serkanalgur
Created May 7, 2020 12:17
Show Gist options
  • Select an option

  • Save serkanalgur/d19328a8f1a68af99c46ca0c43eabf6f to your computer and use it in GitHub Desktop.

Select an option

Save serkanalgur/d19328a8f1a68af99c46ca0c43eabf6f to your computer and use it in GitHub Desktop.

Revisions

  1. serkanalgur created this gist May 7, 2020.
    20 changes: 20 additions & 0 deletions 30gunyorumkapatmak.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?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');