I' m looking for a function which can be inserted in wordpress theme function.php , when inserted , i want it to update a random post (which is already posted ) every 10 minutes .

can this be done through cron job or by simple writing a php code in function.php.

  • 1
    what research have you done and what have you tried? – Milo Feb 27 '15 at 4:10
  • Something like .... <?php $my_post=query_posts('showposts=1&orderby=rand'); wp_update_post( $my_post ); ?> i m not sure , my php knowledge is very limited ! – pradip Feb 27 '15 at 5:31
  • 1
    Could you elaborate so we can have a wider idea of what you want to achieve? – jepser Feb 27 '15 at 5:45

You could use wp_schedule_event to schedule recurring tasks. The smallest precision it normally supports is "hourly" but you can use wp_get_schedules to create a custom "ten_minutes" interval.

Or, you could use wp_schedule_single_event to just trigger the event once and have that scheduled task schedule the next event ten minutes later.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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