Display most popular in the past two days
Hi I'm using this code below to display the most popular post on my wordpress site. It works great! I was wondering if there was anyway to show the most popular post of the current day?
This in my functions.php
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
return $count.' Views';
}
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}
else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
and this in my theme file
?php
global $post;
$args = array( 'numberposts' = 5, 'offset'= 1, 'category' = 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?
lia href="?php the_permalink(); ?"?php the_title(); ?/a/li
li?php setPostViews(get_the_ID()); echo getPostViews(get_the_ID());; ?/li
?php endforeach; ?
Topic popular-posts functions wp-query Wordpress
Category Web