Advertisement
Guest User

Untitled

a guest
Oct 30th, 2013
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. How to list most commented posts from last 24h/today, this week, this month, this year or all time? Or since X days ago.
  2.  
  3. <?php
  4. $popular = new WP_Query( array(
  5. 'post_type' => array( 'post' ),
  6. 'showposts' => 6,
  7. 'cat' => 'culture',
  8. 'ignore_sticky_posts' => true,
  9. 'orderby' => 'comment_count date',
  10. 'date_query' => array(
  11. array(
  12. 'after' => array(
  13. 'year' => date( "Y" ),
  14. 'month' => date( "m" ),
  15. 'day' => "01",
  16. ),
  17. 'before' => array(
  18. 'year' => date( "Y" ),
  19. 'month' => date( "m", strtotime( "-1 Months" ) ),
  20. 'day' => date( "t", strtotime( "-1 Months" ) ),
  21. ),
  22. // 'inclusive' => true,
  23. 'month' => date( "m" ),
  24. ),
  25. ),
  26. ) );
  27. ?>
  28.  
  29. <?php while ( $popular->have_posts() ): $popular->the_post(); ?>
  30.  
  31. <?php the_title(); ?>
  32.  
  33. <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement