date based condition
-
I’d like to add a date based condition to the code I have to reset the counter on every Sunday 00:00:00 but I can’t figure out how to do it.
This is what I have, but it doesn’t reset the counter to 0.
//COUNT PAGEVIEWS function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); $today = date('l H:i:s'); if($count=='' || $today == 'Sunday 00:00:00') { $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } }Anyone with ideas?
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘date based condition’ is closed to new replies.