How to implement a counter that adds value once a day to WordPress?

  • one
    And where does wordpress ? - MichaelPak
  • I advise you to explain in more detail what you need. So you will increase the chances of getting practical advice. - s976

1 answer 1

The following code should be added to the function.php theme file:

 if ( ! wp_next_scheduled( 'my_task_hook' ) ) { wp_schedule_event( time(), 'daily', 'my_task_hook' ); 

}

 function my_task_function() { $counter = get_option('my_counter', 0); $counter++; update_option('my_counter', $counter); // использовать $counter } add_action( 'my_task_hook', 'my_task_function' ); 

and use the $ counter variable where the comment is, or read it in the right place in the code with get_option, as in the example.