I am trying to execute an update query from my functions.php using init hook.
Here is my code
add_action('init', 'process_query');
function process_query(){
$wpdb->query("UPDATE $table_name SET status='inactive' WHERE CURRENT_DATE NOT BETWEEN startdate AND enddate");
}
Now this query works fine when i directly run it on PHPmyadmin’s SQL section. But if i put it to functions.php, the theme goes down and i get a blank webpage.
I have checked WordPress codex syntax for “update” query but it requires arrays. So it won’t work for me in that way.
Use Following Code