Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to make a scheduled event which trigger two 'update_post_meta' registered in function_1 and function_2.

Here is the code I have so far.

   function function_1($post_ID=0){
   ~~~~
        update_post_meta($post_ID, '_score_1', $score_1); 
        return $score_1;
   }
   add_action ('save_post', 'function_1');

   function function_2($post_ID=0){
   ~~~~
        update_post_meta($post_ID, '_score_2', $score_2); 
        return $score_2;
    }
   add_action ('save_post', 'function_2');

This part works perfect, and I can call this action in the content area too. However as I put a wp_schedule_event, it seems not working, probably my lack of understanding. Here is a code in question

    add_action( 'wp', 'hotness_update_activation' );
    function hotness_update_activation() {
         if ( ! wp_next_scheduled( 'hourly_hotness_update' ) ) {
            wp_schedule_event( current_time( 'UNIX_TIMESTAMP' ), 'hourly','hourly_hotness_update' );
        }
    }

    add_action( 'hourly_hotness_update', 'hourly_hotness_update_callback' );
    function hourly_hotness_update_callback() {

        foreach ( $posts as $post ) {
            function_1( $post->ID );
            function_2( $post->ID );    
        }
    }

It does not trigger anything. Any help would be greatly appreciated.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.