Jump to content

Wendi

Members
  • Posts

    5
  • Joined

Wendi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I managed with a different approach, because I was stuck for the above reasons. I put the delete and add lines in a separate php file and run a cronjob every week. But thanks again for putting me on the right track.
  2. Thank you Psycho for the reply. It makes sense. I'm going to puzzle a bit with the ideas above and see what works for me. Thank you all
  3. Eiseth solution works, but what DaveyK says is also true. When no one goes to the webpage at exactly that time there is no counter reset. Maybe a better question is: how to reset the counter ON a specific day and time.
  4. I want to count the pageviews and based on the number of pageviews I want to order the posts on my homepage. That part works already. But what I also want is to reset the counter once a week to start all over again. In this way I'll have the posts on my homepage where people are most interested in that week.
  5. 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); } } Could someone help me with this? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.