0

From the discussion setting, I found that WordPress can turn off the comment automatically when you don't get any comments for a certain days. I am trying to write a function so that I can change the post category from cat1 to cat2 when the post does not get any new comments for two weeks. Is there anyone who knows hooks for that action?

2
  • Hi bigevent, could you provide more details on what you've tried already (and why it didn't work)?
    – kraftner
    Dec 16, 2015 at 19:17
  • Hi Kraftner, I did not start any coding yet. It would be good to know what the hook is for checking post inactivity for a certain period of time.
    – bigevent
    Dec 16, 2015 at 23:26

1 Answer 1

0

https://codex.wordpress.org/Function_Reference/wp_schedule_event You can try using scheduled job to solve this.

In the hook, you would write a function that checks all posts from yesterday and see which posts have received no comments. Then you will move those posts to cat 2 from cat 1. I would come up with mock code if you can give me more context of

  • how many posts you have
  • Do you want the scheduled job to run once a day

This approach is simple to implement and will definitely work for small number of posts but if you post thousands of new posts everyday, then it would slow down your site while the scheduled job is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.