The code below is from this link. It basically creates a hit counter, but I'm probably gonna have to do this by IP.
How do I make a WP_Query, where only posts up to 1000 views can be seen on the trending list? Of course. I would want to do it by date as well, but it won't appear at the top one after another, it will only be in the list where it was originally posted. So, that's another solution I'm gonna need to figure out.
This is similar to 9GAG.
//Add to functions.php
function get_hits(){
global $post;
$hits = get_post_meta($post->ID, '_hit-counter', true);
return $hits;
}
function update_hits($count){
global $post;
$count = $count ? $count : 0;
$hits = update_post_meta($post->ID, '_hit-counter', $count++);
return $hits;
}
//Usage within the loop
update_hits(get_hits());
