0

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.

3
  • 1
    what research have you done and what have you tried?
    – Milo
    Commented Feb 27, 2015 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
    Commented Feb 27, 2015 at 5:31
  • 1
    Could you elaborate so we can have a wider idea of what you want to achieve?
    – jepser
    Commented Feb 27, 2015 at 5:45

1 Answer 1

0

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.

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.