Support

Account

Home Forums General Issues Automatically add 7 days to Date Time Picker

Solved

Automatically add 7 days to Date Time Picker

  • Hello,
    Let’s say I am picking the date 05.03.2019 which is a Tuesday and a certain time. Is it possible to automatically update the date to the next Thursday once this date is over?

    I want to use this to plan and display events in a calendar that are happening every week on the same days. My calendar is sorting and inserting the events based on their dates and times.

    Thanks in advance for your answers.

  • You would need to set up a cron to do this. https://codex.wordpress.org/Function_Reference/wp_cron

    I would suggest a cron on the server set in your site control panel rather than a cron in WP because you will need to do a query to get all the posts that might have the date field, loop through all of the posts, get the date field for each post, check to see if it has passed and if it has update the field.

    On a site with only a few post that need to be looked at using WP to do the cron will probably work. But if you have a lot of posts it will slow your site down and may even time out page loads.

  • That did the trick, thank you ^^

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Automatically add 7 days to Date Time Picker’ is closed to new replies.