[HOWTO] Display number of spams stopped since your blog started.
So i wanted to display total number of spam coments blocked by askismet. Checking the the plugins source i found this function which returns the number:
[php]get_option(‘akismet_spam_count’);[/php]
Getting the blogs first post date was the tricky bit and required a database query:
[php]$firstpost = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND ID >0 LIMIT 1");[/php]
The query checks the first post above zero as most people delete post #1.
So the complete code is:
[php]<?php echo get_option(‘akismet_spam_count’); ?> Spams caught since
< ?php
$firstpost = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND ID >0 LIMIT 1");
echo gmdate(‘M Y’,strtotime($firstpost));
?>[/php]
the result looks like this:
10253 Spams caught since Jun 2006
[…] Continued here:Â [HOWTO] Display number of spams stopped since your blog started. […]
I don’t usually reply to posts but I will in this case, great info…I will add a backlink and bookmark your site. Keep up the good work!
I’m Out! 🙂