arie_cristianD

filter popular post query by published date

Feb 17th, 2026
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. add_filter('jnews_view_counter_query_where', 'j_custom_popular_weekly', 99 , 2);
  2.  
  3. function j_custom_popular_weekly($where , $instance){
  4.     $week = 1; /* Total Week */
  5.     $days = $week * 7;
  6.     $now      = current_time('mysql');
  7.     $from_dt  = gmdate('Y-m-d H:i:s', strtotime($now . " -{$days} days"));
  8.     $where .= " AND p.post_date BETWEEN '{$from_dt}' AND '{$now}'";
  9. return $where;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment