• Hi
    I want to update automatically specific custom field to new specific value after 70 days from published post . ( i have 6000 posts in my blog )
    for example in beginning create post set “level_tutorial” = “advanced”
    i want set after 70 days “level_tutorial” to “Beginner”
    tanks!
    I know a little bit about ( update_post_meta ) but I do not know how to put in this case

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Use wp_schedule_event() to run a script daily. In that script query for all posts published between 69 and 70 days in the past. Loop through each post and update the post meta.

    Since updating the meta more than once does no harm, you may want to set a wider interval than exactly 24 hours to ensure nothing gets passed over because the overlap was not enough. So maybe query between 69 and 71 days back. You can also schedule tasks more often and reduce the time spread accordingly if you want a more accurate transition. Scheduled tasks do not execute exactly on time, the actual time depends on how busy your site is. Someone has to visit after the established time to trigger the task.

    Thread Starter salar2016

    (@salar2016)

    i need code ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to update post meta when 70 days of published post’ is closed to new replies.