New answers tagged get-comments
1
You can try this query that counts user comments by using the user_id field in the comments table as a filter:
function count_user_comments_today( $uid ){
global $wpdb;
$today = date('Y-m-d');
$tomorrow = date('Y-m-d', time() + 86400);
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d ...
1
I don't know of a way to directly pull this query with Core functions, but the SQL is simple.
$sql = "SELECT COUNT(comment_ID)
FROM {$wpdb->comments}
WHERE comment_author = 'admin'
AND DATE(comment_date) = FROM_UNIXTIME('".time()."')";
$a = $wpdb->get_var($sql);
You can alternately use something like AND DATE(comment_date) ...
1
Yes it's definitely possible. Refer to http://codex.wordpress.org/Function_Reference/get_comment, you'll need to get the current server time in UNIX format and then convert comment_date_gmt from each returned be using a foreach loop
function current_user_comments_today() {
global $comment;
global $current_user;
get_currentuserinfo();
$all_user_comments ...
3
To print just the total number of comments for a given post ID, use the count argument:
echo get_comments(
array (
// post ID
'post_id' => 149,
// return just the total number
'count' => TRUE
)
);
To get the total number of all comments of all posts on the current page, you can use the comment_count property ...
Top 50 recent answers are included