• Hello all, I would like to be able to add an expiry date to my posts so that after a future date, the comments are turned off..

    anyone know of a plugin that would do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • See: https://codex.www.ads-software.com/Settings_Discussion_Screen

    Automatically close comments on articles older than [X] days – Check the box and enter the number of days (e.g. 14 days) after which WordPress will automatically flag eligible posts so that no more comments are accepted.

    No plugin required!

    Thread Starter vwdforum

    (@vwdforum)

    thanks for your reply, but the issue I’ve got is my site is custom and posts are added by contributors.

    I have look at another mod which seems to do what I want apart from this mod deletes the post once a date is reached using the below code

    wp_delete_post ($a->post_id);

    Can anyone advice me what I should replace the above to turn off “add comments” so no further comments can be added?

    thanks Mally

    Without seeing the surrounding code, you could try replacing that line with;

    $exp_post = array();
    $exp_post['ID'] = $a->post_id;
    $exp_post['comment_status'] = 'closed';
    $exp_post['ping_status'] = 'closed';
    wp_update_post( $exp_post );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to stop comments after a certain date’ is closed to new replies.