Sort posts by "Popular" – What is wrong with this code?
-
I’m trying to sort my posts by popular. This will be defined as the most viewed posts in the last 2 days. The following code doesn’t work and I cannot figure it out:
WP_Query( array('ignore_sticky_posts' => 1, 'showposts' => 5, 'days' => 2, 'orderby' => 'meta_value_num', 'order' => 'desc') );I currently have this set for most viewed in total and it works:
WP_Query( array('ignore_sticky_posts' => 1, 'showposts' => 5, 'meta_key' => '_count-views_all', 'orderby' => 'meta_value_num', 'order' => 'desc') );I have tried this and it doesn’t work either
WP_Query( array('ignore_sticky_posts' => 1, 'showposts' => 5, 'meta_key' => '_count-views_all', 'days' => 2, 'orderby' => 'meta_value_num', 'order' => 'desc') );Can anyone advise what is wrong with this.. Thanks in advance !
The topic ‘Sort posts by "Popular" – What is wrong with this code?’ is closed to new replies.