Skip to content

Instantly share code, notes, and snippets.

@wpmu-authors
Created February 8, 2021 14:10
Show Gist options
  • Save wpmu-authors/18b469efacd0a8461c54d1919abb708e to your computer and use it in GitHub Desktop.
Save wpmu-authors/18b469efacd0a8461c54d1919abb708e to your computer and use it in GitHub Desktop.
commentcount.php
global $wpdb;
for( $i=1; $i <= 5; $i++ ) {
$this_week = 7 * $i;
$last_week = 7 * ( $i - 1);
$comment_counts[] =
$wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_date > '" . date('Y-m-d H:i:s', strtotime('-' . $this_week . ' days')) . "' AND comment_date < '" . date('Y-m-d H:i:s', strtotime('-' . $last_week . ' days')) . "'" ) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment