Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. add_action('init','engineCreateRecurringSchedule');
  2. add_action('engineRecurringCronJob','engineDaysToGoUpdate');
  3.  
  4.  
  5. function engineDaysToGoUpdate(){
  6.  
  7. // Arguments to get published posts with 'engine' post type.
  8. $engineDaysToGoArgs = get_posts( array (
  9. 'post_status' => 'publish'
  10. 'posts_per_page' => -1,
  11. 'post_type' => 'engine') );
  12.  
  13. // Calling the value of custom field.
  14. $engineDaysToGo = genesis_get_custom_field('wpcf-engine-days-to-go');
  15.  
  16. // Subtracting 1 from the value.
  17. $updatedEngineDaysToGo = $engineDaysToGo--;
  18.  
  19. // Updating the value of the custom field.
  20. for each ($engineDaysToGoArgs as $key => $value) {
  21.  
  22. // Inserting the updated value of the custom field.
  23. $update_post_meta($engineDaysToGoArgs, $engineDaysToGo, $updatedEngineDaysToGo,);
  24.  
  25. }}
  26.  
  27. function engineCreateRecurringSchedule(){
  28.  
  29. // Check to see if event is scheduled before.
  30. if(!wp_next_scheduled('engineRecurringCronJob'))
  31.  
  32. //Schedule to run at midnight every night.
  33. wp_schedule_event (time(), 'daily', 'engineRecurringCronJob');
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement